ProtocolServers
hololinked.injection.ProtocolServers
Bases: Registry
A singleton registry of the protocol servers a Thing can be exposed with.
All members are class attributes and settings are applied process-wide (python process).
from hololinked import ProtocolServers
ProtocolServers.register(WebsocketServerWithMyCustomProtocol, "websockets", protocol="websockets")
thing.run(access_points=[("websockets", 5683)])
# OR
WebsocketServerWithMyCustomProtocol.add_thing(thing)
WebsocketServerWithMyCustomProtocol.run()
Source code in repo/hololinked/hololinked/injection.py
982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 | |
Attributes
http
instance-attribute
HTTP(s) server exposing Things over HTTP 1.1.
mqtt
instance-attribute
MQTT publisher pushing events and observable properties to a broker's topic tree.
zmq
instance-attribute
ZeroMQ server exposing Things over IPC, TCP and INPROC transport.
modules
class-attribute
modules: dict[str, str | tuple[str, str]] = {'http': 'HTTPServer', 'mqtt': 'MQTTPublisher', 'zmq': 'ZMQServer'}
protocols
class-attribute
Protocol name, as given in an access point, mapped to the server that serves it.
Answerable without importing the server, which is what lets an access point select one lazily.
Functions
for_protocol
classmethod
Get the server class that serves a given protocol, importing it if necessary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
the protocol name as given in an access point, for example 'HTTP'. Case insensitive. |
required |
Returns:
| Type | Description |
|---|---|
type[BaseProtocolServer] | None
|
the server class, to be created with its |
Source code in repo/hololinked/hololinked/injection.py
register
classmethod
Register a protocol server under a given name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
type[BaseProtocolServer]
|
the server class to register, must be a subclass of |
required |
|
str
|
the name to register the server under, for example 'http' or 'zmq' |
required |
|
str
|
the protocol name that selects this server in an access point, for example 'HTTP'. Case insensitive. |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
if the server is not a subclass of |