clickhouse

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2026 License: Apache-2.0 Imports: 48 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	PayloadMetadata  PayloadMode = "metadata"
	PayloadProjected PayloadMode = "projected"
	PayloadFull      PayloadMode = "full"

	RetentionManaged  = "managed"
	RetentionExternal = "external"

	PurgeManaged    = "managed"
	PurgeRecordOnly = "record-only"
	PurgeExternal   = "external"
)
View Source
const (
	// ProjectionRowsOne writes one row per matching resource.
	ProjectionRowsOne = "one"
	// ProjectionRowsMany writes zero or more rows per matching resource.
	ProjectionRowsMany = "many"
)

Variables

This section is empty.

Functions

func Command

func Command() *cli.Command

func ProjectionsCommand added in v0.5.0

func ProjectionsCommand() *cli.Command

ProjectionsCommand shows each projection table's manifest chain, combined columns, and logic routing. A chain's definition is spread across several manifests, so this reads the configured manifests without connecting to ClickHouse.

Types

type Batch

type Batch struct {
	ID                 string
	ExporterID         string
	FirstCursor        string
	LastCursor         string
	ObservedAt         time.Time
	Lifecycle          []LifecycleRow
	Fences             []FenceRow
	Purges             []PurgeRow
	Memberships        []MembershipRow
	Projections        []ProjectionRow
	ProjectionFailures []ProjectionFailureRow
}

type ClickHouseSink

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

func OpenSink

func OpenSink(ctx context.Context, cfg Config) (*ClickHouseSink, error)

func (*ClickHouseSink) BackgroundErrors

func (s *ClickHouseSink) BackgroundErrors() <-chan error

func (*ClickHouseSink) Close

func (s *ClickHouseSink) Close() error

func (*ClickHouseSink) EnsureSchema

func (s *ClickHouseSink) EnsureSchema(ctx context.Context, mode string) error

EnsureSchema claims only an empty database or validates this exact current baseline.

func (*ClickHouseSink) HasMembershipRows added in v0.6.0

func (s *ClickHouseSink) HasMembershipRows(ctx context.Context, exporterID, resourceID string) (bool, error)

HasMembershipRows reports whether an earlier membership export left rows for resourceID. The processor calls it only while membership export is off.

func (*ClickHouseSink) MaxIngestVersion added in v0.6.0

func (s *ClickHouseSink) MaxIngestVersion(ctx context.Context, exporterID string) (uint64, error)

MaxIngestVersion returns the highest row version stored for exporterID across every versioned table, including registered projection tables.

func (*ClickHouseSink) ResolvePurge added in v0.6.0

func (s *ClickHouseSink) ResolvePurge(ctx context.Context, purge PurgeRow) (PurgeRow, error)

func (*ClickHouseSink) WriteBatch

func (s *ClickHouseSink) WriteBatch(ctx context.Context, batch Batch) error

type Common

type Common struct {
	ExporterID    string
	BatchID       string
	EventID       string
	SourceCursor  string
	IngestVersion uint64
	ObservedAt    time.Time
}

type Config

type Config struct {
	ExportMemberships          bool
	ExporterID                 string
	Addresses                  []string
	Protocol                   string
	Database                   string
	Username                   string
	Password                   string
	PasswordFile               string
	TLS                        bool
	CAFile                     string
	AllowInsecureClickHouse    bool
	SchemaMode                 string
	PayloadMode                PayloadMode
	AllowDecryptedContent      bool
	MetadataKeys               []string
	ProjectionPaths            []string
	ProjectionFailurePolicy    string
	ProjectionReplayID         string
	Disable                    []string
	RetentionMode              string
	PurgeMode                  string
	LifecycleRetention         time.Duration
	TombstoneRetention         time.Duration
	ProjectionRetention        time.Duration
	ProjectionFailureRetention time.Duration
	TailOnlyDevelopment        bool
	BatchEvents                int
	BatchRows                  int
	BatchBytes                 int
	MaxRecordBytes             int
	BatchDelay                 time.Duration
	RetryMin                   time.Duration
	RetryMax                   time.Duration
}

Config controls one analytics export.

func (*Config) Validate

func (c *Config) Validate() error

type FenceRow added in v0.6.0

type FenceRow struct {
	Common
	ResourceKind        string
	ResourceID          string
	ConversationID      string
	ConversationGroupID string
}

type LifecycleRow

type LifecycleRow struct {
	Common
	OccurredAt          time.Time
	ResourceKind        string
	AnalyticsResourceID string
	Action              string
	Change              string
	ConversationID      string
	ConversationGroupID string
	ContentType         string
	MemoryKind          string
	SnapshotAvailable   bool
}

type MembershipRow added in v0.6.0

type MembershipRow struct {
	Common
	ResourceID          string
	ConversationGroupID string
	UserID              string
	AccessLevel         string
	CreatedAt           *time.Time
	IsDeleted           bool
}

type PayloadMode

type PayloadMode string

type Processor

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

func NewProcessor

func NewProcessor(cfg Config, sink Sink) (*Processor, error)

func (*Processor) BackgroundErrors

func (p *Processor) BackgroundErrors() <-chan error

func (*Processor) Bootstrap

func (p *Processor) Bootstrap(ctx context.Context, events processruntime.EventClient, save func(context.Context) error) (string, error)

func (*Processor) ContentType

func (p *Processor) ContentType() string

func (*Processor) Flush

func (p *Processor) Flush(ctx context.Context) error

func (*Processor) Handle

func (*Processor) Load

func (p *Processor) Load(raw json.RawMessage) error

func (*Processor) SetLeaseGeneration

func (p *Processor) SetLeaseGeneration(generation uint64) error

func (*Processor) Snapshot

func (p *Processor) Snapshot() (json.RawMessage, error)

type Projection

type Projection struct {
	Name     string
	Digest   string
	Resource string
	Ordering string
	// Selector is the content type or memory kind the manifest adds to its chain. It is
	// empty for later manifests that only replace logic or add columns.
	Selector    string
	TableName   string
	RowMode     string
	ColumnNames []string
	Columns     map[string]projectionColumn
	// Previous names the manifest before this one; it is empty for the first manifest of a chain.
	Previous               string
	ProjectionRegoReplaces string
	ProjectionRegoFrom     string
	AddColumns             map[string]projectionColumn
	// contains filtered or unexported fields
}

Projection is one loaded AnalyticsProjection manifest. Manifests form chains: the first manifest of a chain defines the table, and each later manifest names the manifest before it. After loading, TableName, RowMode, ColumnNames, and Columns describe the chain's shared table, so every manifest in a chain writes the same column set.

func (*Projection) Rows

func (p *Projection) Rows(ctx context.Context, base ProjectionRow, input map[string]any) ([]ProjectionRow, string)

Rows evaluates the projection for one resource snapshot. It returns the rows to write, or a payload-free error code when any row is invalid. The base row supplies the shared resource identity and event metadata.

func (*Projection) TombstoneRow

func (p *Projection) TombstoneRow(base ProjectionRow) ProjectionRow

TombstoneRow returns the row that marks the resource as deleted in the projection table.

type ProjectionFailureRow

type ProjectionFailureRow struct {
	Common
	ResourceKind        string
	AnalyticsResourceID string
	ConversationID      string
	ConversationGroupID string
	ProjectionName      string
	ErrorCode           string
	AttemptCount        uint32
	FirstSeenAt         time.Time
	LastSeenAt          time.Time
}

type ProjectionRow

type ProjectionRow struct {
	Common
	ProjectionName      string
	TableName           string
	ResourceID          string
	ConversationID      string
	ConversationGroupID string
	IsDeleted           bool
	// Multi marks rows for tables created with `rows: many`; RowIndex and RowCount are only written for them.
	Multi       bool
	RowIndex    uint32
	RowCount    uint32
	ColumnNames []string
	Values      []any
}

type ProjectionSet

type ProjectionSet struct {
	Items  []*Projection
	Tables []*ProjectionTable
	Digest string
	// contains filtered or unexported fields
}

func LoadProjectionSet

func LoadProjectionSet(ctx context.Context, paths []string) (*ProjectionSet, error)

func (*ProjectionSet) Match added in v0.5.0

func (s *ProjectionSet) Match(resource, selector string) []*Projection

Match returns the manifests whose logic projects resources of the given kind and selector, one per table, ordered by table name.

type ProjectionTable added in v0.5.0

type ProjectionTable struct {
	Name     string
	Resource string
	RowMode  string
	Ordering string
	// Manifests lists the chain in order, starting with the manifest that defines the table.
	Manifests []*Projection
	// ColumnNames is sorted; Columns holds the first manifest's columns plus every addColumns.
	ColumnNames []string
	Columns     map[string]projectionColumn
	// ColumnOrder is the physical column order: the first manifest's columns sorted by name,
	// then each manifest's addColumns sorted by name, in chain order.
	ColumnOrder []string
	// ColumnOwners maps each column to the manifest that declared it.
	ColumnOwners map[string]string
	// Logic maps each covered content type or memory kind to the manifest whose logic
	// projects it.
	Logic map[string]*Projection
}

ProjectionTable is one projection chain and the table its manifests write to.

type PurgeRow

type PurgeRow struct {
	ExporterID          string
	BatchID             string
	PurgeID             string
	EventID             string
	ResourceKind        string
	AnalyticsResourceID string
	ConversationID      string
	ConversationGroupID string
	Scope               string
	CutoffIngestVersion uint64
	RequestedAt         time.Time
}

type RunningProcessor

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

func StartProcessor

func StartProcessor(ctx context.Context, opts StartOptions) (*RunningProcessor, error)

func (*RunningProcessor) Shutdown

func (p *RunningProcessor) Shutdown(ctx context.Context) error

func (*RunningProcessor) Wait

func (p *RunningProcessor) Wait() error

type Sink

type Sink interface {
	EnsureSchema(context.Context, string) error
	ResolvePurge(context.Context, PurgeRow) (PurgeRow, error)
	WriteBatch(context.Context, Batch) error
	Close() error
}

type StartOptions

type StartOptions struct {
	Capabilities       capabilityClient
	Endpoint           string
	ClientID           string
	APIKey             string
	OIDC               processruntime.OIDCConfig
	AfterCursor        string
	CheckpointInterval time.Duration
	LeaseTTL           time.Duration
	HealthAddress      string
	GRPCTLS            bool
	GRPCCAFile         string
	AllowInsecureGRPC  bool
	Config             Config
	Events             processruntime.EventClient
	Checkpoints        processruntime.CheckpointClient
	Sink               Sink
}

Jump to

Keyboard shortcuts

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