octobot_channels.channels package

Submodules

octobot_channels.channels.channel module

class octobot_channels.channels.channel.Channel[source]

Bases: object

CONSUMER_CLASS = None
INSTANCE_KEY = 'consumer_instance'
PRODUCER_CLASS = None
add_new_consumer(consumer, consumer_filters) → None[source]

Add a new consumer to consumer list with filters :param consumer: the consumer to add :param consumer_filters: the consumer selection filters (used by ‘get_consumer_from_filters’) :return: None

flush() → None[source]
get_consumer_from_filters(consumer_filters) → list[source]
get_consumers() → list[source]

Returns all consumers instance Can be overwritten according to the class needs :return: the subscribed consumers list

get_internal_producer(**kwargs) → None[source]

Returns internal producer if exists else creates it :param kwargs: arguments for internal producer __init__ :return: internal producer instance

classmethod get_name() → str[source]

Default implementation is to return the name of the class without the ‘Channel’ substring :returns the channel name

get_producers(**kwargs) → Iterable[source]

Should be overwritten according to the class needs :param kwargs: producers list filter params :return: channel producers iterable

async modify(**kwargs) → None[source]

Call each registered producers modify method :return: None

async new_consumer(callback: object = None, consumer_filters: dict = None, internal_consumer: object = None, size: int = 0, filter_size: bool = False, **kwargs) → None[source]

Create an appropriate consumer instance for this channel and add it to the consumer list Should end by calling ‘_check_producers_state’ :param callback: method that should be called when consuming the queue :param consumer_filters: the consumer filters :param size: queue size, default 0 :param internal_consumer: internal consumer instance to use if specified :param filter_size: if the consumer wants a filtered flow :return: consumer instance created

async register_producer(producer, **kwargs) → None[source]

Add the producer to producers list Can be overwritten to perform additional action when registering Should end by calling ‘pause’ if self.is_paused :param Producer producer: created channel producer to register :param kwargs: additional arguments available for overwritten methods :return: None

async remove_consumer(consumer: None, **kwargs) → None[source]

Should be overwritten according to the class needs Should end by calling ‘_check_producers_state’ and then ‘consumer.stop’ :param consumer: consumer instance to remove from consumers list :param kwargs: consumers list filter params :return: None

async run() → None[source]

Call each registered consumers run method :return: None

async start() → None[source]

Call each registered consumers start method :return: None

async stop() → None[source]

Call each registered consumers and producers stop method :return: None

unregister_producer(producer, **kwargs) → None[source]

Remove the producer from producers list Can be overwritten to perform additional action when registering :param Producer producer: created channel producer to unregister :param kwargs: additional arguments available for overwritten methods :return: None

octobot_channels.channels.channel.del_chan(name) → None[source]

Delete a Channel instance from the channels list according to channel name :param name: name of the channel to delete :return: None

octobot_channels.channels.channel.get_chan(chan_name: str, **kwargs) → octobot_channels.channels.channel.Channel[source]

Return the channel instance from channel name :param chan_name: the channel name :param kwargs: :return: the Channel instance

octobot_channels.channels.channel.set_chan(chan, name) → octobot_channels.channels.channel.Channel[source]

Set a new Channel instance in the channels list according to channel name :param chan: new Channel instance :param name: name of the channel :return: the channel instance if succeed else raise a ValueError

octobot_channels.channels.channel_instances module

class octobot_channels.channels.channel_instances.ChannelInstances[source]

Bases: octobot_commons.singleton.singleton_class.Singleton

Singleton that contains Channel instances

Module contents