hololinked.core.zmq.brokers.AsyncZMQServer
Bases: BaseZMQServer
, BaseAsyncZMQ
Implements both blocking (non-polled) and non-blocking/polling form of receive messages and send replies
This server can be stopped from server side by calling stop_polling()
unlike AsyncZMQServer
which
cannot be stopped manually unless a message arrives.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
str
|
|
required |
|
server type metadata - currently not useful/important |
required | |
|
Union[Context, None]
|
ZeroMQ Context object to use. All sockets share this context. Automatically created when None is supplied. |
None
|
|
SocketType
|
socket type of ZMQ socket, default is ROUTER (enables address based routing of messages) |
ROUTER
|
|
ZMQ_TRANSPORTS
|
Use TCP for network access, IPC for multi-process applications, and INPROC for multi-threaded applications. |
IPC
|
|
time in milliseconds to poll the sockets specified under |
25
|
Source code in hololinked\core\zmq\brokers.py
306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 |
|
Functions
__init__
__init__(*, id: str, context: typing.Union[zmq.asyncio.Context, None] = None, socket_type: zmq.SocketType = zmq.ROUTER, transport: ZMQ_TRANSPORTS = ZMQ_TRANSPORTS.IPC, poll_timeout=25, **kwargs) -> None
Source code in hololinked\core\zmq\brokers.py
async_recv_request
async
Receive one message in a blocking form. Async for multi-server paradigm, each server should schedule
this method in the event loop explicitly. This is taken care by the Eventloop
& RPCServer
.
Returns:
Name | Type | Description |
---|---|---|
message |
RequestMessage
|
received message with important content (operation, arguments, thing execution context) deserialized. |
Source code in hololinked\core\zmq\brokers.py
async_recv_requests
async
Receive all currently available messages in blocking form. Async for multi-server paradigm, each server should schedule
this method in the event loop explicitly. This is taken care by the Eventloop
& RPCServer
.
Returns:
Name | Type | Description |
---|---|---|
messages |
List[RequestMessage]
|
list of received messages with important content (operation, arguments, execution context) deserialized. |
Source code in hololinked\core\zmq\brokers.py
async_send_response
async
async_send_response(request_message: RequestMessage, payload: SerializableData = SerializableNone, preserialized_payload: PreserializedData = PreserializedEmptyByte) -> None
Send response message for a request message.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
RequestMessage
|
original message so that the response can be properly crafted and routed |
required |
|
serializable data to be sent as response |
required | |
|
pre-encoded data, generally used for large or custom data that is already serialized |
required |
Returns:
Type | Description |
---|---|
None
|
|
Source code in hololinked\core\zmq\brokers.py
async_send_response_with_message_type
async
async_send_response_with_message_type(request_message: RequestMessage, message_type: str, payload: SerializableData = SerializableNone, preserialized_payload: PreserializedData = PreserializedEmptyByte) -> None
Send response message for a request message.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
RequestMessage
|
original message so that the response can be properly crafted and routed |
required |
|
serializable data to be sent as response |
required |
Returns:
Type | Description |
---|---|
None
|
|
Source code in hololinked\core\zmq\brokers.py
poll_requests
async
poll for messages with specified timeout (poll_timeout
) and return if any messages are available.
This method blocks, so make sure other methods are scheduled which can stop polling.
Returns:
Name | Type | Description |
---|---|---|
messages |
List[List[bytes]]
|
list of received messages with important content (operation, arguments, thing execution context) deserialized. |
Source code in hololinked\core\zmq\brokers.py
_handshake
async
Inner method that handles handshake. Scheduled by handshake()
method, signature same as handshake()
.
Source code in hololinked\core\zmq\brokers.py
_handle_timeout
async
Inner method that handles timeout. Scheduled by handle_timeout()
, signature same as handle_timeout
.
Source code in hololinked\core\zmq\brokers.py
_handle_invalid_message
async
Inner method that handles invalid messages. Scheduled by handle_invalid_message()
,
signature same as handle_invalid_message()
.
Source code in hololinked\core\zmq\brokers.py
exit
unregister socket from poller and terminate socket and context.