Help us shape the future of Go! Take the 2026 Go Developer Survey

workerdaemon

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(ctx context.Context, c Config, logger *slog.Logger) error

Run owns its pools and runs one explicitly configured tenant and worker mode. It cancels in-flight delivery on shutdown; unacknowledged leases remain retryable.

func RunLoop

func RunLoop(ctx context.Context, processor Processor, timeout, poll time.Duration) error

func RunOrphanLoop

func RunOrphanLoop(ctx context.Context, ticker OrphanTicker, interval, timeout time.Duration, logger *slog.Logger) error

func RunProjectionCleanupLoop

func RunProjectionCleanupLoop(ctx context.Context, ticker ProjectionCleanupTicker, interval, timeout time.Duration, logger *slog.Logger) error

func RunSweepLoop

func RunSweepLoop(ctx context.Context, ticker SweepTicker, interval, timeout time.Duration) error

RunSweepLoop emits the current UTC bucket immediately and then at interval boundaries. Each emission is bounded; outages do not replay historical ticks.

Types

type ArchiveConfig

type ArchiveConfig struct {
	Tenant      string            `json:"tenant"`
	Stream      string            `json:"stream"`
	Directory   string            `json:"directory"`
	KeyID       string            `json:"key_id"`
	TrustedKeys map[string]string `json:"trusted_keys"`
}

func (*ArchiveConfig) Validate

func (c *ArchiveConfig) Validate() error

type AuditConfig

type AuditConfig struct {
	Tenant string `json:"tenant"`
	Stream string `json:"stream"`
	KeyID  string `json:"key_id"`
}

type Config

type Config struct {
	ProjectionCleanup      *ProjectionCleanupConfig     `json:"projection_cleanup,omitempty"`
	OrphanCleanup          *workers.OrphanCleanupConfig `json:"orphan_cleanup,omitempty"`
	Telemetry              *runtimeconfig.Telemetry     `json:"telemetry,omitempty"`
	OpenFGATraceContext    bool                         `json:"openfga_trace_context,omitempty"`
	Extraction             *ExtractionConfig            `json:"extraction"`
	Refresh                *RefreshConfig               `json:"refresh"`
	Archive                *ArchiveConfig               `json:"archive"`
	Audit                  AuditConfig                  `json:"audit"`
	Mode                   string                       `json:"mode"`
	Principal              string                       `json:"principal"`
	Projection             runtimeconfig.LexicalRoute   `json:"projection"`
	OpenFGAURL             string                       `json:"openfga_url"`
	OpenFGAStore           string                       `json:"openfga_store"`
	OpenFGAModel           string                       `json:"openfga_model"`
	MaxConnections         int32                        `json:"max_connections"`
	MaxAttempts            int                          `json:"max_attempts"`
	LeaseSeconds           int                          `json:"lease_seconds"`
	PollMilliseconds       int                          `json:"poll_milliseconds"`
	MinBackoffMilliseconds int                          `json:"min_backoff_milliseconds"`
	MaxBackoffSeconds      int                          `json:"max_backoff_seconds"`
	DeliveryTimeoutSeconds int                          `json:"delivery_timeout_seconds"`
}

func LoadConfig

func LoadConfig(path string) (Config, error)

func (Config) Validate

func (c Config) Validate() error

type ExtractionConfig

type ExtractionConfig struct {
	Tenant     string                              `json:"tenant"`
	Stream     string                              `json:"stream"`
	Scheduling *runtimeconfig.ExtractionScheduling `json:"scheduling"`
	Gateways   []ExtractionGateway                 `json:"gateways"`
}

func (*ExtractionConfig) Validate

func (c *ExtractionConfig) Validate() error

type ExtractionGateway

type ExtractionGateway struct {
	PropagateTraceContext  bool   `json:"propagate_trace_context,omitempty"`
	ProfileID              string `json:"profile_id"`
	URL                    string `json:"url"`
	TokenEnv               string `json:"token_env,omitempty"`
	RootCAFile             string `json:"root_ca_file,omitempty"`
	AllowPlaintextLoopback bool   `json:"allow_plaintext_loopback,omitempty"`
}

type OrphanTicker

type OrphanTicker interface {
	Tick(context.Context) (workers.OrphanCleanupResult, error)
}

type Processor

type Processor interface {
	ProcessOne(context.Context) (bool, error)
}

type ProjectionCleanupConfig

type ProjectionCleanupConfig struct {
	workers.ProjectionCleanupConfig
	Destinations []runtimeconfig.CleanupRoute `json:"destinations"`
}

func (*ProjectionCleanupConfig) Validate

func (c *ProjectionCleanupConfig) Validate() error

type ProjectionCleanupTicker

type ProjectionCleanupTicker interface {
	Tick(context.Context) (workers.ProjectionCleanupResult, error)
}

type RefreshBinding

type RefreshBinding struct {
	Scope     string `json:"scope"`
	ProfileID string `json:"profile_id"`
}

type RefreshConfig

type RefreshConfig struct {
	RedactionPolicyVersions []string                  `json:"redaction_policy_versions,omitempty"`
	SweepIntervalMinutes    int                       `json:"sweep_interval_minutes,omitempty"`
	Tenant                  string                    `json:"tenant"`
	Stream                  string                    `json:"stream"`
	Purpose                 string                    `json:"purpose"`
	Bindings                []RefreshBinding          `json:"bindings"`
	Profiles                []model.ExtractionProfile `json:"profiles"`
	MaxConcurrentPerTenant  int                       `json:"max_concurrent_per_tenant"`
	DailyTokenBudget        int64                     `json:"daily_token_budget"`
	CostUnit                string                    `json:"cost_unit"`
	DailyCostBudgetUnits    int64                     `json:"daily_cost_budget_units"`
}

func (*RefreshConfig) Validate

func (c *RefreshConfig) Validate() error

type SweepTicker

type SweepTicker interface {
	Tick(context.Context, time.Time) ([]model.CommitResult, error)
}

Jump to

Keyboard shortcuts

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