Skip to content

Configuration api

Configuration API

In hyrrokkin, package configurations are implemented using a python class which implements methods described in hyrrokkin_engine.configuration_interface.ConfigurationInterface:

ConfigurationInterface

Source code in hyrrokkin_engine/configuration_interface.py
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
class ConfigurationInterface:

    @abstractmethod
    def __init__(self, services:ConfigurationService):
        """
        Create an instance of this Configuration

        Args:
            services: an object providing useful services, for example to get or set property values
        """
        pass

    @abstractmethod
    async def load(self):
        """
        Called after construction.  Load any resources associated with this Configuration
        """
        pass

    @abstractmethod
    async def create_node(self, node_type_id:str, service:NodeServiceInterface):
        """
        Create a node which is defined within this package

        :param node_type_id: the id of the node type (a valid key in the schema's node_types dictionary)
        :param service: a service instance which will provide services to the node

        :return: an instance of the node
        """
        pass

    @abstractmethod
    def decode(self, encoded_bytes:bytes, link_type:str) -> Any:
        """
        Decode binary data into a value valid for a particular link type

        :param encoded_bytes: binary data to decode
        :param link_type: the link type associated with the value
        :return: decoded value
        """
        pass

    @abstractmethod
    def encode(self, value:Any, link_type: str) -> bytes:
        """
        Encode a value associated with a link type to binary data

        :param value: the value to encode
        :param link_type: the link type associated with the value
        :return: binary data that encodes the value
        """
        pass

    @abstractmethod
    def open_session(self, session_id):
        """
        Called when a new session starts
        """
        pass

    @abstractmethod
    def close_session(self, session_id):
        """
        Called when a session closes
        """
        pass

    @abstractmethod
    def open_client(self, session_id:str, client_name:str, client_options:dict, client_service:ClientServiceInterface):
        """
        Called when a client is attached to the configuration

        Arguments:
            session_id: a unique identifier for the session to which the client belongs
            client_name: the name of the client, matching details in the schema
            client_options: a set of parameters accompanying the connection
            client_service: a service instance allowing messages to be sent to and received from the client
        """
        pass

    @abstractmethod
    def close_client(self, session_id:str, client_name:str):
        """
        Called when a client is detached from the configuration

        Arguments:
            session_id: a unique identifier for the session to which the client belongs
            client_name: the name of the client, matching details in the schema
        """
        pass

__init__(services) abstractmethod

Create an instance of this Configuration

Parameters:

Name Type Description Default
services ConfigurationService

an object providing useful services, for example to get or set property values

required
Source code in hyrrokkin_engine/configuration_interface.py
30
31
32
33
34
35
36
37
38
@abstractmethod
def __init__(self, services:ConfigurationService):
    """
    Create an instance of this Configuration

    Args:
        services: an object providing useful services, for example to get or set property values
    """
    pass

close_client(session_id, client_name) abstractmethod

Called when a client is detached from the configuration

Parameters:

Name Type Description Default
session_id str

a unique identifier for the session to which the client belongs

required
client_name str

the name of the client, matching details in the schema

required
Source code in hyrrokkin_engine/configuration_interface.py
108
109
110
111
112
113
114
115
116
117
@abstractmethod
def close_client(self, session_id:str, client_name:str):
    """
    Called when a client is detached from the configuration

    Arguments:
        session_id: a unique identifier for the session to which the client belongs
        client_name: the name of the client, matching details in the schema
    """
    pass

close_session(session_id) abstractmethod

Called when a session closes

Source code in hyrrokkin_engine/configuration_interface.py
88
89
90
91
92
93
@abstractmethod
def close_session(self, session_id):
    """
    Called when a session closes
    """
    pass

create_node(node_type_id, service) abstractmethod async

Create a node which is defined within this package

:param node_type_id: the id of the node type (a valid key in the schema's node_types dictionary) :param service: a service instance which will provide services to the node

:return: an instance of the node

Source code in hyrrokkin_engine/configuration_interface.py
47
48
49
50
51
52
53
54
55
56
57
@abstractmethod
async def create_node(self, node_type_id:str, service:NodeServiceInterface):
    """
    Create a node which is defined within this package

    :param node_type_id: the id of the node type (a valid key in the schema's node_types dictionary)
    :param service: a service instance which will provide services to the node

    :return: an instance of the node
    """
    pass

decode(encoded_bytes, link_type) abstractmethod

Decode binary data into a value valid for a particular link type

:param encoded_bytes: binary data to decode :param link_type: the link type associated with the value :return: decoded value

Source code in hyrrokkin_engine/configuration_interface.py
59
60
61
62
63
64
65
66
67
68
@abstractmethod
def decode(self, encoded_bytes:bytes, link_type:str) -> Any:
    """
    Decode binary data into a value valid for a particular link type

    :param encoded_bytes: binary data to decode
    :param link_type: the link type associated with the value
    :return: decoded value
    """
    pass

encode(value, link_type) abstractmethod

Encode a value associated with a link type to binary data

:param value: the value to encode :param link_type: the link type associated with the value :return: binary data that encodes the value

Source code in hyrrokkin_engine/configuration_interface.py
70
71
72
73
74
75
76
77
78
79
@abstractmethod
def encode(self, value:Any, link_type: str) -> bytes:
    """
    Encode a value associated with a link type to binary data

    :param value: the value to encode
    :param link_type: the link type associated with the value
    :return: binary data that encodes the value
    """
    pass

load() abstractmethod async

Called after construction. Load any resources associated with this Configuration

Source code in hyrrokkin_engine/configuration_interface.py
40
41
42
43
44
45
@abstractmethod
async def load(self):
    """
    Called after construction.  Load any resources associated with this Configuration
    """
    pass

open_client(session_id, client_name, client_options, client_service) abstractmethod

Called when a client is attached to the configuration

Parameters:

Name Type Description Default
session_id str

a unique identifier for the session to which the client belongs

required
client_name str

the name of the client, matching details in the schema

required
client_options dict

a set of parameters accompanying the connection

required
client_service ClientServiceInterface

a service instance allowing messages to be sent to and received from the client

required
Source code in hyrrokkin_engine/configuration_interface.py
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
@abstractmethod
def open_client(self, session_id:str, client_name:str, client_options:dict, client_service:ClientServiceInterface):
    """
    Called when a client is attached to the configuration

    Arguments:
        session_id: a unique identifier for the session to which the client belongs
        client_name: the name of the client, matching details in the schema
        client_options: a set of parameters accompanying the connection
        client_service: a service instance allowing messages to be sent to and received from the client
    """
    pass

open_session(session_id) abstractmethod

Called when a new session starts

Source code in hyrrokkin_engine/configuration_interface.py
81
82
83
84
85
86
@abstractmethod
def open_session(self, session_id):
    """
    Called when a new session starts
    """
    pass