====== DWSC control module ======
===== Message format =====
Message serializer: MessagePack
==== Request ====
class DWSCReq {
public $v = 1; // version
public $id = 0; // message ID
public $at = null; // auth token
public $s = ""; // source:
public $t = ""; // target: edge | origin | "*" |
public $vh = ""; // virtual host
public $a = ""; // application
public $c = 0; // command: DWSCCmd
public $p = null; // parameter array
public function DWSCReq() {
$this->p = array();
}
};
==== Reply ====
class DWSCRep {
public $v = 1; // version
public $eno = 0; // error code
public $estr = ""; // error string
public $d = null; // reply data
}
==== Commands ====
class DWSCCmd {
const LOAD = 1;
const SUSPEND = 2;
const STOP = 3;
const SUSPEND = 4;
const DISCONNECT_CLIENTS = 5;
const NOCLUSTER = 6;
const ONLINE = 7;
const RESULT = 8;
const SRVSTATUS = 9;
const VHOSTSLOAD = 10;
}
==== msgpack ====
$msg = new DWSCReq();
$msg->c = DWSCCmd::STOP;
$msgpack = new MessagePack(false); // false = disable PHP_ONLY mode
$smsg = $msgpack->pack($msg);
echo var_export(msgpack_unserialize($smsg), true);
====== Admin ======
ZeroMQ context is registered as a service in the Admin system.
$socket = $this->get('docler_zero_mq.socket');
This creates a context and a socket object, then returns with an instance. The returned //ZeroMQSocket// contains the message pack module too, which is accessible through the //getMessagePack()// method.
You can access the DWSC message formats classess in the //Docler\ZeroMQBundle\Protocol// namespace.
The default //send()// method packs the message (as //recv()// which unpacks it):
public function send(DWSCRequest $msg, $pack = true) { }
public function recv($unpack = true) { }
==== ZeroMQSocket parameters ====
config.yml:
docler_zero_mq:
context_io_threads: 1
context_is_persistent: false
socket_type: SOCKET_REQ
socket_dsn: //this is the only required parameter//
socket_persistent_id: //null//
socket_opts:
SOCKOPT_SNDHWM: 100