kaira.channels.ChannelRegistry

Inheritance diagram of ChannelRegistry

Inheritance diagram for ChannelRegistry

class kaira.channels.ChannelRegistry[source]

Bases: object

A registry for channels in Kaira.

This class provides a centralized registry for all channels, making it easier to instantiate them by name with appropriate parameters.

Methods

__init__

create

Create a channel instance by name.

get

Get a channel class by name.

list_channels

List all available channels in the registry.

register

Register a new channel in the registry.

register_channel

Decorator to register a channel class in the registry.

classmethod register(name: str, channel_class: Type[BaseChannel]) None[source]

Register a new channel in the registry.

Parameters:
  • name (str) – The name to register the channel under.

  • channel_class (Type[BaseChannel]) – The channel class to register.

classmethod register_channel(name: str | None = None) Callable[source]

Decorator to register a channel class in the registry.

Parameters:

name (Optional[str], optional) – The name to register the channel under. If None, the class name will be used (converted to lowercase).

Returns:

A decorator function that registers the channel class.

Return type:

callable

classmethod get(name: str) Type[BaseChannel][source]

Get a channel class by name.

Parameters:

name (str) – The name of the channel to get.

Returns:

The channel class.

Return type:

Type[BaseChannel]

Raises:

KeyError – If the channel is not registered.

classmethod create(name: str, **kwargs) BaseChannel[source]

Create a channel instance by name.

Parameters:
  • name (str) – The name of the channel to create.

  • **kwargs – Additional arguments to pass to the channel constructor.

Returns:

The instantiated channel.

Return type:

BaseChannel

classmethod list_channels() list[source]

List all available channels in the registry.

Returns:

A list of channel names.

Return type:

list

__init__()