-
Notifications
You must be signed in to change notification settings - Fork 1
Client Server Service Reference
mcyph edited this page Feb 4, 2020
·
1 revision
-
.ini
file format
# Flask web monitor related
[web monitor]
port=5155
host=127.0.0.1
# The values in "defaults" will be used if they aren't
# overridden in individual methods
[defaults]
# The location for the time series data (memory data etc)
# and stdout/stderr logs
log_dir=/tmp/test_server_logs/
# The address to bind to (if you want to also allow connection via TCP).
# If you don't, a NetworkServer will not be created.
tcp_bind=127.0.0.1
# The maximum number of worker processes. Defaults to the
# number of CPU cores when not specified.
# Some services which need exclusive access to a resource,
# e.g. write access to a SQLite database may need this to
# be set to 1 only.
max_proc_num=1
# The minumum number of workers. Defaults to 1
min_proc_num=1
# Whether to wait for the service to boot before moving on to the next
# entry: each entry is executed in sequential order if True
wait_until_completed=True
# Whether to allow insecure serialisation methods like pickle/marshal
# in combination with NetworkServer
force_insecure_serialisation=False
# The name of the ServerMethodsBase-derived class to import,
# and the module from which to import the class.
# This is basically the same as
# from module_name import MethodsClassName
# in python.
[MethodsClassName]
import_from=module_name
-
ClientMethodsBase
: The class from which client methods must derive from. This might include logic that allows for creating e.g. class instances from basic types like lists, which can be better supported by JSON and other encoders. The__init__
method takes a single parameter -client_provider
, which may be either anSHMClient
or aNetworkClient
instance. -
ServerMethodsBase
: The class from which client server methods must derive. Subclasses must have a uniqueport
number, and a uniquename
for identification in logs. -
NetworkClient
/SHMClient
: Instances of one of these must be provided toClientMethodsBase
-derived classes. TheNetworkClient
requires a single parameter ofhost
.
Different kinds of encoders/decoders:
-
@raw_method
: Define a method which sends/receives data using the python rawbytes
type -
@json_method
: Define a method sends/receives data using the built-in json module. Tested the most, and quite interoperable: I generally use this, unless there's a good reason not to. -
@msgpack_method
: Define a method that sends/receives data using the msgpack module. Supports most/all the types supported by json, but typically is 2x+ faster, at the expense of (potentially) losing interoperability. -
@pickle_method
: Define a method that sends/receives data using thepickle
module. Potentially insecure as arbitrary code could be sent, but is fast, and supports many python types. Supports int/tuple etc keys in dicts, which json/msgpack don't. -
@marshal_method
: Define a method that sends/receives data using thepickle
module. Potentially insecure as there could be potential buffer overflow vulnerabilities etc, but is fast.