Triggers

class CronTrigger(
mask: str,
start: datetime | None = None,
end: datetime | None = None,
)

Bases: object

Categories:

trigger

Represents a cron-based trigger for scheduling Tabsdata publishers, subscribers and transformers.

This class defines a trigger based on a cron expression, with optional start and end times to constrain its activation period. It validates the cron mask and time boundaries to ensure the trigger is well-formed.

property end: str | None

Gets the end time of the trigger as a timezone-aware ISO 8601 string with ‘Z’ timezone.

Returns:

The end time in ISO format, or None if not set.

property mask: str

Gets the cron expression mask.

Returns:

The cron expression string.

property start: str | None

Gets the start time of the trigger as a timezone-aware ISO 8601 string with ‘Z’ timezone.

Returns:

The start time in ISO format, or None if not set.

class KafkaTrigger(
**kwargs,
)

Bases: StageTrigger

Categories:

trigger

A StageTrigger that consumes messages from a Kafka topic and stages them.

This trigger connects to a Kafka cluster, consumes messages from a specified topic, and uses rollover conditions (time, size, and message count) to buffer and stage the data.

property conn: KafkaConn

Kafka consumer connection configuration.

property data_format: Literal['avro', 'json'] | Protobuf

Data format of the messages (“avro”, “json”, “protobuf”).

property dlq_topic: str | None

Dead-letter queue topic.

property group_id: str | None

Kafka consumer group ID.

property messages_rollover: Annotated[int, Gt(gt=0)] | None

Message count-based rollover configuration.

run(
context: StageTriggerContext,
)

Run the Kafka stage trigger to consume messages, buffer them, and stage them based on rollover conditions.

Parameters:

context – The StageTriggerContext instance.

property schema: str

Schema string for deserializing messages.

property size_rollover_mb: Annotated[int, Gt(gt=0)] | None

Size-based rollover configuration. Size is specified in megabytes.

property time_rollover_secs: int

Timeout in seconds for consuming each message.

property topic: str

Kafka topic to consume from.