caspia.gateway package

Subpackages

Submodules

caspia.gateway.cidmanagement module

class caspia.gateway.cidmanagement.CidManagement(cache_path: pathlib.Path, config=None, maxcid=511)[source]

Bases: object

Manages cid assignments on a can network.

CAN ID lease (assignment) process:

  1. The search of available cids is narrowed to cids allowed

    for that node.

  2. If there is an existing lease for the node within the allowed cids

    range, that cid is assigned/leased again.

  3. If there is a cid reservation for that node, that cid will be

    leased to the node.

  4. If there is any available cid, that cid will be leased to the node.

  5. If there is cid reservation for some other node (which is not leased yet),

    that cid will be leased to the node.

  6. Otherwise CanIDReservationError will be raised.

allow_cids(pattern, cid_range)[source]
available_cids_for(name)[source]
cid_of(name, *, reserved=False)[source]

Return cid of a node with given name.

By default searches for nodes having this cid leased. If reserved is True, searches also for nodes having the cid reserved.

configure(config)[source]

Configure allowed cids using a config dictionary.

first_available_cid_for(name)[source]
is_leased(cid)[source]
is_reserved(cid)[source]
lease(name, cid=None)[source]
name_of(cid, *, reserved=False)[source]

Return name of a node having assigned given cid.

By default searches for nodes having this cid leased. If reserved is True, searches also for nodes having the cid reserved.

reserve(name, cid)[source]
save()[source]
class caspia.gateway.cidmanagement.Reservation(cid: int, node: str, leased: bool)[source]

Bases: object

Can ID reservation.

When a node has a cid reservation, it means, that there is a preference of that node having the cid in future. No guarantees included. On the other side, if the reservation is leased, it is guaranted that the cid won’t be assigned to some other node.

caspia.gateway.configurator module

class caspia.gateway.configurator.Configurator(hwid_map, network, lookup, loop, work_dir, rules_filter)[source]

Bases: object

async configure()[source]
property gateway_services
property nodes_configured
async prepare_nodes()[source]

Make sure all nodes are reachable through known CID.

caspia.gateway.errors module

exception caspia.gateway.errors.CanIDReservationError[source]

Bases: Exception

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception caspia.gateway.errors.ConfigurationError[source]

Bases: Exception

args
property messages
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception caspia.gateway.errors.ConfigurationSemanticError[source]

Bases: caspia.gateway.errors.ConfigurationError

args
property messages
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception caspia.gateway.errors.ConfigurationSyntaxError[source]

Bases: caspia.gateway.errors.ConfigurationError

args
property messages
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

caspia.gateway.gateway module

class caspia.gateway.gateway.CaspiaGateway(*, name, connection, config_path, storage_path, pollen_client, consumer_conn, rules_filter=<RulesFilter.ALL: 'all'>)[source]

Bases: caspia.meadow.client.gateway.Gateway

Bridge between Caspia CAN Components and Meadow Services.

add(services: Iterable[Union[GatewayServiceMixin, caspia.meadow.services.ServiceBase]], update_immediately=False)

Register service(s) for the gateway.

property busy
async configure()[source]
configure_cidmanagement()[source]
property connection
async handle_rules_request(rules)[source]
property hwid_map
init_monitors()[source]
load_services()[source]
async load_states()[source]
on_component_event(node_cid, component_id, component_type, event)[source]
on_component_event_processed(name, component, task)[source]
async on_gateway_registered()
on_raw_broadcast(*args, **kwargs)[source]
async prepare()
prepare_service(service)[source]
remove(services: Iterable[Union[GatewayServiceMixin, caspia.meadow.services.ServiceBase]], update_immediately=False)

Remove service(s) from the gateway.

request_delayed_configuration()[source]
property services

All registered services for the gateway.

async setup()[source]
async update_active_rules()[source]

caspia.gateway.network module

class caspia.gateway.network.Network(pollen_client, cidmng: caspia.gateway.cidmanagement.CidManagement)[source]

Bases: object

Manages Caspia CAN Network

get_configured_component(node, comp_cls, comp_cfg)[source]

Return existing or a new Component instance configured based on given config

get_node(name)[source]

Return node for a given name. Create a new one, if it does not exist yet.

reset_configuration()[source]

Module contents