source

package
v1.0.0-rc.2 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultSourceBuffer = 64

DefaultSourceBuffer is the capacity used for the per-source message channel that connectors place decoded change events onto.

It is intentionally small: a shallow buffer absorbs short bursts while applying backpressure to the producer (the upstream database/stream reader) as soon as the downstream sink lags, instead of hoarding up to a thousand fully-decoded messages in RAM per active pipeline. With multi-KB payloads and several concurrent pipelines, deep buffers were a primary driver of the resident set; bounding them keeps Hermod within its lightweight footprint.

Variables

This section is empty.

Functions

func ConnectGocql

func ConnectGocql(ctx context.Context, cluster *gocql.ClusterConfig) (*gocql.Session, error)

ConnectGocql establishes a gocql session without blocking past the caller's context.

gocql exposes no context-aware CreateSession: it blocks for its own ConnectTimeout (and retries across the host list) regardless of what the caller asked for. Against an unreachable cluster that is tens of seconds. A readiness probe with a two-second budget therefore does not time out — it hangs, holding a goroutine, and reports nothing either way.

This runs the connect off the caller's goroutine and returns as soon as either the session is ready or ctx is done.

The spawned goroutine is not leaked. The result channel is buffered, so a late CreateSession still completes rather than blocking forever on send, and the abandoned session is closed so an established connection is not stranded.

Types

type MetricsSource

type MetricsSource struct {
	hermod.Source
	// contains filtered or unexported fields
}

MetricsSource wraps a Source and records metrics.

func NewMetricsSource

func NewMetricsSource(s hermod.Source, sourceID, workflowID string, onRead func(time.Duration)) *MetricsSource

func (*MetricsSource) DiscoverColumns

func (s *MetricsSource) DiscoverColumns(ctx context.Context, table string) ([]hermod.ColumnInfo, error)

func (*MetricsSource) DiscoverDatabases

func (s *MetricsSource) DiscoverDatabases(ctx context.Context) ([]string, error)

func (*MetricsSource) DiscoverPublications

func (s *MetricsSource) DiscoverPublications(ctx context.Context) ([]hermod.PublicationInfo, error)

func (*MetricsSource) DiscoverReplicationSlots

func (s *MetricsSource) DiscoverReplicationSlots(ctx context.Context) ([]hermod.ReplicationSlotInfo, error)

func (*MetricsSource) DiscoverTables

func (s *MetricsSource) DiscoverTables(ctx context.Context) ([]string, error)

func (*MetricsSource) ExecuteSQL

func (s *MetricsSource) ExecuteSQL(ctx context.Context, query string) ([]map[string]any, error)

func (*MetricsSource) GetLag

func (s *MetricsSource) GetLag(ctx context.Context) (uint64, error)

GetLag forwards lag reporting to the wrapped source.

MetricsSource embeds the hermod.Source interface, and embedding an interface does not promote methods the interface does not declare — so wrapping a PostgresSource silently hid its GetLag. Every lag-based check downstream (workflow status, WAL-retention alerting, the stall watchdog) therefore read zero and concluded there was no outstanding work, which is exactly wrong when a replication slot is retaining WAL because the pipeline has stopped.

func (*MetricsSource) GetState

func (s *MetricsSource) GetState() map[string]string

func (*MetricsSource) IsReady

func (s *MetricsSource) IsReady(ctx context.Context) error

func (*MetricsSource) LastStreamActivity

func (s *MetricsSource) LastStreamActivity() time.Time

LastStreamActivity forwards stream liveness from the wrapped source, for the same reason GetLag has to be forwarded: an embedded interface does not promote methods it does not declare, and a hidden liveness signal reads as "this source has no stream to watch" rather than as "this source's stream is fine".

func (*MetricsSource) PendingWork

func (s *MetricsSource) PendingWork() (pending bool, known bool)

PendingWork forwards the wrapped source's outstanding-work signal. A source that cannot answer reports false, which leaves the stall watchdog on its lag fallback rather than asserting there is nothing outstanding.

func (*MetricsSource) Read

func (s *MetricsSource) Read(ctx context.Context) (hermod.Message, error)

func (*MetricsSource) Sample

func (s *MetricsSource) Sample(ctx context.Context, table string) (hermod.Message, error)

func (*MetricsSource) SetLogger

func (s *MetricsSource) SetLogger(logger hermod.Logger)

func (*MetricsSource) SetState

func (s *MetricsSource) SetState(state map[string]string)

func (*MetricsSource) Snapshot

func (s *MetricsSource) Snapshot(ctx context.Context, tables ...string) error

func (*MetricsSource) StreamSilenceThreshold

func (s *MetricsSource) StreamSilenceThreshold() time.Duration

StreamSilenceThreshold forwards the wrapped source's silence deadline. Zero for a source that does not hold a push stream, which disables the check.

type PollingSource

type PollingSource struct {
	// contains filtered or unexported fields
}

PollingSource is a generic implementation of a source that polls a database for changes.

func NewPollingSource

func NewPollingSource(db *sql.DB, query string, interval time.Duration, watermarkCol string, initialWatermark any) *PollingSource

func (*PollingSource) Ack

func (s *PollingSource) Ack(ctx context.Context, msg hermod.Message) error

func (*PollingSource) Close

func (s *PollingSource) Close() error

func (*PollingSource) Ping

func (s *PollingSource) Ping(ctx context.Context) error

func (*PollingSource) Read

func (s *PollingSource) Read(ctx context.Context) (hermod.Message, error)

func (*PollingSource) SetLogger

func (s *PollingSource) SetLogger(logger hermod.Logger)

Jump to

Keyboard shortcuts

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