kafka

package
v0.19.1237 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 9, 2026 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TopicRunnerHeartBeats = "runner_heart_beats"
	TopicOtelLogRecords   = "otel_log_records"
	TopicOtelTraces       = "otel_traces"
	TopicDLQ              = "dlq"
)

Topics this service produces to / consumes from. Names mirror the destination ClickHouse tables.

View Source
const (
	TypeRunnerHeartBeat = "runner_heart_beat"
	TypeOtelLogRecord   = "otel_log_record"
	TypeOtelTrace       = "otel_trace"
	TypeDLQ             = "dlq_record"
)

Envelope message types.

Variables

This section is empty.

Functions

func ClientConfig

func ClientConfig(cfg *internal.Config) pkgkafka.Config

ClientConfig maps ctl-api config into the generic Kafka client config. Shared by the producer here and the domain consumers.

func ClientID

func ClientID(cfg *internal.Config) string

ClientID identifies this process to the brokers. Kafka reports it in request metrics, broker logs, and consumer group member ids, and — the reason it is worth being specific — applies client quotas per client id, so a shared value would make it impossible to throttle one producer without throttling all of them. It is also stamped into every envelope as the message source.

Derived from the same service_type/service_deployment that tag our pods in Datadog, so a client id here names the deployment the same way the dashboards do: ctl-api/api-runner, ctl-api/worker-installs, ctl-api/consumer-clickhouse-sink.

func ConsumerConfig

func ConsumerConfig(cfg *internal.Config, name, topic string) pkgkafka.ConsumerConfig

ConsumerConfig maps ctl-api config into the generic consumer config for one topic. The fetch tunables are process-wide config, set per deployment, since each consumer runs in its own pod.

func ConsumerGroup

func ConsumerGroup(cfg *internal.Config, name string) string

ConsumerGroup names the group for one consumer. Per-consumer rather than one shared group because a group with heterogeneous topic subscriptions rebalances every member whenever any member restarts — so a deploy of one consumer would stall the others for no reason.

Changing a group's name makes it start from the earliest retained offset (pkgkafka sets ConsumeResetOffset to AtStart), which for a topic with history means replaying the whole retention window. Rename only while a topic is cold, or seed the new group from the old one's committed offsets first.

func New

func New(params Params) (*pkgkafka.Producer, error)

New provides the shared Kafka producer. When KAFKA_ENABLED is false it returns a no-op producer so callers fall back to their legacy inline path and downstream writes never depend on Kafka being present.

Types

type Message

type Message = pkgkafka.Message

type Params

type Params struct {
	fx.In

	Cfg *internal.Config
	L   *zap.Logger
	MW  metrics.Writer
	LC  fx.Lifecycle
}

type Producer

type Producer = pkgkafka.Producer

Producer and Message are re-exported so ctl-api call sites depend on this glue package rather than the generic transport directly.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL