Antano » Antano Server API » UnixService
Antano® will be released very soon. This is an announcement text

Contents

Search

UnixService

class services.UnixService(_server, _params, _type=<SocketKind.SOCK_DGRAM: 2>, _family=<AddressFamily.AF_UNSPEC: 0>)

Bases: services.SocketService

UnixService – this service is a special way how we will communicate with a particular process Since we are not able to get complex data from one to another process it is necessarily to communicate between them via UnixSockets

Parameters:{UnixSocket} -- basic class (SocketService) –

Methods Summary

add_accept_handler(sock, callback) Accept Handler for UDP Socket
add_sockets(sockets) Adds speficic sockets to the server
bind(port[, address, family]) Bind a specific socket (here UDP) to the server
bind_unix_socket(file, mode) Special binding for UnixSockets - the way unix-sockets are reused depends extremly on OS Platform
can_send() Basic info wether service can send back or not
close() Basic close service
get_service(_params[, _server]) Gets a service from service params EXAMPLE: _params[‘active_service’].append({ # tcp service “id”: 2, “antano_server_id”: 1, # needs to be the same as id above “service_type_id”: 2, “port”: 18002, “host”: “0.0.0.0”, “endpoint”: “”, # in case of rest or websocket /my_endpoint put “my_endpoint” “message_format_in_id”: 1, # message_format “message_format_out_id”: 1, # message_format })
on_received_message(message, address, …) On received message will process the message and if there is a repsonse it will send back to the same stream the client has send
pass_through_message(_entity, _entity_id, …) Passes through a message via UNIX socket
run_processes(_services, _num_of_process) Finally runs all processes for given sockets this is mandatory for creating port bindings after creating sub-processes
send_message(message, address, stream[, …]) Basic send message from service
start(_params[, _internal]) Special start for UNIX communication socket
start_internal_service(server) Starts an internal service for unix socket
stop() Stops a service immediately

Methods Documentation

add_accept_handler(sock, callback)

Accept Handler for UDP Socket

Parameters:
  • {socket} -- Socket object (sock) –
  • {function} -- callBackFunction (callback) –
Keyword Arguments:
 

{IOLoop Obj} -- Current IOLoop (default (io_loop) – {None})

add_sockets(sockets)

Adds speficic sockets to the server

Parameters:{[Dict]} -- Dict of Sockets (sockets) –
bind(port, address=None, family=<AddressFamily.AF_UNSPEC: 0>)

Bind a specific socket (here UDP) to the server

Parameters:

{int} -- [port number] (port) –

Keyword Arguments:
 
  • {string} -- [Address string] (default (address) – {None})
  • {Socket.Family} -- [Socket.Family] (default (family) – {socket.AF_UNSPEC})
  • {int} -- [description] (default (backlog) – {25})
bind_unix_socket(file, mode)

Special binding for UnixSockets - the way unix-sockets are reused depends extremly on OS Platform

Parameters:
  • {string} -- file name (file) –
  • {int} -- chmod mode (mode) –
Keyword Arguments:
 

{int} -- current backlog (default (backlog) – {128})

Returns:

Socket obj – the current socket

static can_send()

Basic info wether service can send back or not

Returns:bool – can send back?
close()

Basic close service

static get_service(_params, _server=None)

Gets a service from service params EXAMPLE: _params[‘active_service’].append({

# tcp service “id”: 2, “antano_server_id”: 1, # needs to be the same as id above “service_type_id”: 2, “port”: 18002, “host”: “0.0.0.0”, “endpoint”: “”, # in case of rest or websocket /my_endpoint put “my_endpoint” “message_format_in_id”: 1, # message_format “message_format_out_id”: 1, # message_format

})

Parameters:{Dict<String, Obj>} -- service param (_params) –
Returns:Service obj – a service
on_received_message(message, address, sock_stream)

On received message will process the message and if there is a repsonse it will send back to the same stream the client has send

Parameters:
  • {bytes[]} -- message data (message) –
  • {Tuple (address) –
  • {mixed} -- Socket or SOCK_STREAM (sock) –
Returns:

[bytes[]] – response

pass_through_message(_entity, _entity_id, _process_id, message)

Passes through a message via UNIX socket

Parameters:
  • {String} -- entity name (_entity) –
  • {Int} -- entity ID (_entity_id) –
  • {Int} -- process id (_process_id) –
  • {Dict<String, obj>} -- common message object (message) –
static run_processes(_services, _num_of_process)

Finally runs all processes for given sockets this is mandatory for creating port bindings after creating sub-processes

Parameters:
  • {array} -- array of services (_services) –
  • {int} -- number of processes to start (_num_of_process) –
send_message(message, address, stream, is_binary=False)

Basic send message from service

Parameters:
  • {bytes[]} -- message data (message) –
  • {Tuple (address) –
  • {mixed} -- Socket or SOCK_STREAM (sock) –
start(_params, _internal=False)

Special start for UNIX communication socket

Parameters:{Dict<String,obj>} -- current service params (_params) –
Keyword Arguments:
 {bool} -- is internal communication or not (default (_internal) – {False})
static start_internal_service(server)

Starts an internal service for unix socket

Parameters:{Server} -- AntanoServer obj (server) –
Returns:Dict<string, obj> – a Service Params dict
stop()

Stops a service immediately

Last update: 10/08/2020 3:43 a.m. (CET)