api

package
v0.0.0-...-3d597f3 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LogFormat

type LogFormat string
const (
	// LogFormatText indicates that logs should be written in text format.
	LogFormatText LogFormat = "text"

	// LogFormatJSON indicates that logs should be written in JSON format.
	LogFormatJSON LogFormat = "json"
)

type LogOptions

type LogOptions struct {
	// The log output type.
	Output LogOutput

	// The log format.
	Format LogFormat

	// The log level.
	Level string

	// The log file path. Only used if Output is LogOutputFile.
	FilePath string
}

LogOptions contains options for logging.

type LogOutput

type LogOutput string
const (
	// LogOutputStdout indicates that logs should be written to stdout.
	LogOutputStdout LogOutput = "stdout"

	// LogOutputStderr indicates that logs should be written to stderr.
	LogOutputStderr LogOutput = "stderr"

	// LogOutputFile indicates that logs should be written to a file.
	LogOutputFile LogOutput = "file"

	// LogOutputNone indicates that no logs should be written.
	LogOutputNone LogOutput = "none"
)

type OnErrorStrategy

type OnErrorStrategy int
const (
	// OnErrorExit causes the process to exit if its internal function returns an error.
	OnErrorExit OnErrorStrategy = iota

	// OnErrorRestart causes the process to be restarted if its internal function returns an error.
	OnErrorRestart
)

type Options

type Options struct {
	// The logging configuration.
	Log LogOptions

	// The pubsub configuration.
	PubSub PubSubOptions

	// Whether to enable opentelemetry.
	// If nil, opentelemetry is disabled.
	Telemetry *telemetry.Options
}

Options contains options for the runtime.

type Proc

type Proc interface {
	Spawn(ctx context.Context, fn ProcessFn, opts SpawnOptions) ProcessHandle
}

type ProcessFn

type ProcessFn func(state *ProcessState) error

type ProcessHandle

type ProcessHandle interface {
	IsRunning() bool
	PID() uint64
	Stop()
	Wait()
}

type ProcessState

type ProcessState struct {
	Ctx context.Context
	Log *slog.Logger
	Rt  Runtime
}

type PubSub

type PubSub interface {
	CreateTopic(name string, bufferSize uint32) error
	Subscribe(topicName, subscriptionName string) (SubscriptionHandle, error)
	Publish(ctx context.Context, topicName string, payload any) error
	Close()
}

type PubSubOptions

type PubSubOptions struct {
	MaxBufferSize uint32
}

PubSubOptions contains options for the pubsub system.

type Runtime

type Runtime interface {
	BlockUntilSignal()
	Close()

	Proc() Proc
	PubSub() PubSub
	Scheduler() Scheduler
}

type Scheduler

type Scheduler interface {
	Schedule(process ProcessFn, opts SpawnOptions, interval time.Duration)
}

type SpawnOptions

type SpawnOptions struct {
	// The error handling strategy for the process.
	OnError OnErrorStrategy

	// The name of the process.
	Name string

	// Whether to create a telemetry span for the process.
	Instrument bool
}

type SubscriptionHandle

type SubscriptionHandle interface {
	Data() <-chan any
	Close()
}

Jump to

Keyboard shortcuts

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