minos.plugins.kafka.subscriber

Classes

KafkaBrokerSubscriber

Kafka Broker Subscriber class.

KafkaBrokerSubscriberBuilder

Kafka Broker Subscriber Builder class.

class KafkaBrokerSubscriber[source]

Bases: BrokerSubscriber, KafkaCircuitBreakerMixin

Kafka Broker Subscriber class.

__init__(topics, host=None, port=None, group_id=None, remove_topics_on_destroy=False, **kwargs)[source]
Parameters
property host: str

The host of kafka.

Returns

A str value.

property port: int

The port of kafka.

Returns

A int value.

property group_id: Optional[str]

The id of kafka’s group.

Returns

An Optional[str]` value.

property remove_topics_on_destroy: int

Flag to check if topics should be removed on destroy.

Returns

A bool value.

admin_client

Get the kafka admin client.

Returns

An KafkaAdminClient instance.

client

Get the kafka consumer client.

Returns

An AIOKafkaConsumer instance.

property already_destroyed: bool

Already Destroy getter.

Returns

A boolean value.

property already_setup: bool

Already Setup getter.

Returns

A boolean value.

property circuit_breaker: aiomisc.circuit_breaker.CircuitBreaker

Get the circuit breaker.

Returns

A CircuitBreaker instance.

property circuit_breaker_exceptions: tuple[type[Exception]]

Get the circuit breaker exceptions.

Returns

A tuple of Exception types.

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

classmethod get_builder()

Get the builder class.

Returns

A Builder instance.

Return type

Builder[Ins]

property is_circuit_breaker_broken: bool

Check if circuit breaker is passing.

Returns

A bool instance.

property is_circuit_breaker_passing: bool

Check if circuit breaker is passing.

Returns

A bool instance.

property is_circuit_breaker_recovering: bool

Check if circuit breaker is passing.

Returns

A bool instance.

async receive()

Receive a new message.

Returns

A BrokerMessage instance.

Return type

BrokerMessage

classmethod set_builder(builder)

Set a builder class.

Parameters

builder (Union[Builder[Ins], type[minos.common.builders.Builder[~Ins]]]) – The builder class to be set.

Returns

This method does not return anything.

Return type

None

async setup()

Setup miscellaneous repository things.

Returns

This method does not return anything.

Return type

None

property topics: set[str]

Topics getter.

Returns

A list of string values.

async with_circuit_breaker(fn)

Execute the given function with circuit breaker.

Parameters

fn (Callable[[], Union[Awaitable[R], R]]) – The function to be executed.

Returns

The return of the given function.

Return type

R

class KafkaBrokerSubscriberBuilder[source]

Bases: BrokerSubscriberBuilder[KafkaBrokerSubscriber], KafkaBrokerBuilderMixin

Kafka Broker Subscriber Builder class.

__init__(*args, validator_builder=None, queue_builder=None, filtered_cls=None, queued_cls=None, **kwargs)
Parameters
property already_destroyed: bool

Already Destroy getter.

Returns

A boolean value.

property already_setup: bool

Already Setup getter.

Returns

A boolean value.

build()

Build the instance.

Returns

A QueuedBrokerSubscriber instance.

Return type

BrokerSubscriber

copy()

Get a copy of the instance.

Returns

A Builder instance.

Parameters

self (type[~B]) –

Return type

B

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

classmethod get_injectable_name()

Get the injectable name.

Returns

A str value.

Return type

str

classmethod new()

Get a new instance.

Returns

A Builder instance.

Return type

B

async setup()

Setup miscellaneous repository things.

Returns

This method does not return anything.

Return type

None

with_cls(cls)

Set class to be built.

Parameters
  • cls (type) – The class to be set.

  • self (B) –

Returns

This method return the builder instance.

Return type

B

with_config(config)

Set config.

Parameters

config (Config) – The config to be set.

Returns

This method return the builder instance.

with_filtered_cls(filtered_cls)

Set the filtered class.

Parameters

filtered_cls (type[FilteredBrokerSubscriber]) – A subclass of FilteredBrokerSubscriber.

Returns

This method return the builder instance.

with_group_id(group_id)

Set group_id.

Parameters

group_id (Optional[str]) – The group_id to be set.

Returns

This method return the builder instance.

with_kwargs(kwargs)

Set kwargs.

Parameters

kwargs (dict[str, Any]) – The kwargs to be set.

Returns

This method return the builder instance.

with_queue(queue)

Set the queue builder.

Parameters

queue (Union[type[BrokerSubscriberQueue], BrokerSubscriberQueueBuilder]) – The queue to be set.

Returns

This method return the builder instance.

with_queued_cls(queued_cls)

Set the queued class.

Parameters

queued_cls (type[QueuedBrokerSubscriber]) – A subclass of QueuedBrokerSubscriber.

Returns

This method return the builder instance.

with_remove_topics_on_destroy(remove_topics_on_destroy)

Set remove_topics_on_destroy.

Parameters

remove_topics_on_destroy (bool) – The remove_topics_on_destroy flag to be set.

Returns

This method return the builder instance.

with_topics(topics)

Set topics.

Parameters

topics (Iterable[str]) – The topics to be set.

Returns

This method return the builder instance.

with_validator(validator)

Set the duplicate detector.

Parameters

validator (Union[type[BrokerSubscriberValidator], Builder[BrokerSubscriberValidator]]) – The duplicate detector to be set.

Returns

This method return the builder instance.