minos.networks.brokers.dispatchers.impl

Classes

BrokerDispatcher

Broker Dispatcher class.

class BrokerDispatcher[source]

Bases: SetupMixin

Broker Dispatcher class.

__init__(actions, publisher, **kwargs)[source]
Parameters
property publisher: minos.networks.brokers.publishers.abc.BrokerPublisher

Get the publisher instance.

Returns

A BrokerPublisher instance.

property actions: dict[str, Optional[collections.abc.Callable]]

Actions getter.

Returns

A dictionary in which the keys are topics and the values are the handler.

async dispatch(message)[source]

Dispatch an entry.

Parameters

message (BrokerMessage) – The entry to be dispatched.

Returns

This method does not return anything.

Return type

None

static get_callback(fn)[source]

Get the handler function to be used by the Broker Handler.

Parameters

fn (Callable[[BrokerRequest], Union[BrokerResponse, None, Awaitable[Optional[BrokerResponse]]]]) – The action function.

Returns

A wrapper function around the given one that is compatible with the Broker Handler API.

Return type

Callable[[BrokerMessage], Awaitable[BrokerMessageV1Payload]]

get_action(topic)[source]

Get the handling function to be called.

Parameters

topic (str) – The name of the topic that matches the action.

Returns

A Callable instance.

Return type

Callable[[Request], Union[Response, None, Awaitable[Optional[Response]]]]

property already_destroyed: bool

Already Destroy getter.

Returns

A boolean value.

property already_setup: bool

Already Setup getter.

Returns

A boolean value.

async destroy()

Destroy miscellaneous repository things.

Returns

This method does not return anything.

Return type

None

classmethod from_config(config=None, **kwargs)

Build a new instance from config.

Parameters
  • config (Optional[Union[Config, Path]]) – Config instance. If None is provided, default config is chosen.

  • kwargs – Additional named arguments.

Returns

A instance of the called class.

Return type

S

async setup()

Setup miscellaneous repository things.

Returns

This method does not return anything.

Return type

None