ZMQServerPool
hololinked.server.zmq.brokers.ZMQServerPool
Bases: BaseZMQServer
Implements pool of async ZMQ servers (& their sockets).
Source code in repo/hololinked/hololinked/server/zmq/brokers.py
801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 | |
Attributes
poll_timeout
property
writable
Socket polling timeout in milliseconds greater than 0.
Functions
__init__
Initialize the server pool.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
list[str] | None
|
list of server IDs to create the server pool. If None, an empty pool is created and servers can be
registered later using |
None
|
|
Additional arguments for
|
{}
|
Source code in repo/hololinked/hololinked/server/zmq/brokers.py
create_socket
create_socket(*, id: str, bind: bool, context: Context | Context, access_point: str, socket_type: SocketType = zmq.SocketType.ROUTER, **kwargs) -> None
Source code in repo/hololinked/hololinked/server/zmq/brokers.py
register_server
Source code in repo/hololinked/hololinked/server/zmq/brokers.py
deregister_server
poll
async
Pool for messages in the entire server pool.
Use the message to identify the server by using receiver_id of the message header.
Returns:
| Type | Description |
|---|---|
list[RequestMessage]
|
list of received messages across all servers in the pool |
Source code in repo/hololinked/hololinked/server/zmq/brokers.py
async_recv_request
async
Receive message for server specified by id.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
id of the ZMQ server |
required |
Returns:
| Type | Description |
|---|---|
RequestMessage
|
received message |
Source code in repo/hololinked/hololinked/server/zmq/brokers.py
async_recv_requests
async
Receive all available messages for server specified by id.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
id of the ZMQ server |
required |
Returns:
| Type | Description |
|---|---|
list[RequestMessage]
|
list of received messages |
Source code in repo/hololinked/hololinked/server/zmq/brokers.py
async_send_response
async
async_send_response(*, id: str, request_message: RequestMessage, payload: SerializableData = SerializableNone, preserialized_payload: PreserializedData = PreserializedEmptyByte) -> None
Send response for a request message for server specified by id.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
id of the ZMQ server |
required |
|
RequestMessage
|
request message for which response is being given |
required |
|
SerializableData
|
serializable data to be sent as response |
SerializableNone
|
|
PreserializedData
|
pre-encoded data to be sent as payload, generally used for large or custom data that is already serialized |
PreserializedEmptyByte
|
Source code in repo/hololinked/hololinked/server/zmq/brokers.py
stop_polling
exit
handshake
Pass a handshake message to client.
Absolutely mandatory to handshake with all clients to ensure initial messages do not get lost because of ZMQ's tiny but significant initial delay after creating socket.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
RequestMessage
|
the client message for which the handshake is being sent |
required |
Source code in repo/hololinked/hololinked/server/zmq/brokers.py
handle_invalid_message
Pass an invalid message to the client when an exception occurred while parsing the message from the client (in handled_default_message_types()).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
RequestMessage
|
the client message for which the parsing exception occurred |
required |
|
Exception
|
exception object raised |
required |
Source code in repo/hololinked/hololinked/server/zmq/brokers.py
handle_timeout
Pass timeout message to the client when the operation could not be executed within specified timeouts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
RequestMessage
|
the client message which could not executed within the specified timeout. timeout value is generally specified within the execution context values. |
required |
Source code in repo/hololinked/hololinked/server/zmq/brokers.py
handle_error_message
Pass an exception message to the client when an exception occurred while executing the operation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
RequestMessage
|
the client message for which the exception occurred |
required |
|
Exception
|
exception object raised |
required |
Source code in repo/hololinked/hololinked/server/zmq/brokers.py
handled_default_message_types
Handle default cases for the server without further processing of the request (for example, HANDSHAKE).
This method is called once/supposed to be called when the message is received or popped out of the socket.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
RequestMessage
|
the client message to handle |
required |
Returns:
| Name | Type | Description |
|---|---|---|
handled |
bool
|
whether the message was handled here and needs no further processing |
Raises:
| Type | Description |
|---|---|
BreakLoop
|
if an |