model

package
v0.9.5 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 10 Imported by: ? 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

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Database added in v0.4.0

type Database interface {
	common.Service
	ORM() *gorm.DB
	DB() *sql.DB
	FromContext(ctx context.Context) *gorm.DB
	FromContextTimeout(ctx context.Context, timeout time.Duration) (*gorm.DB, context.CancelFunc)
	Transaction(ctx context.Context, fn func(tctx context.Context) error, opts ...*sql.TxOptions) error
}

Database deliberately carries nothing destructive; see DatabaseDebugger.

type DatabaseDebugger added in v0.9.0

type DatabaseDebugger interface {
	// Cleanup empties every table; with schema it drops and recreates the schema.
	Cleanup(schema bool) error
	Reload() error
}

DatabaseDebugger is for tests and tooling, reachable only through the manager itself.

type MessageBus added in v0.4.1

type MessageBus interface {
	common.Service

	// Register delivers to module via whichever of MessageHandler and
	// RawMessageHandler it implements.
	Register(module common.Named)

	// senders never receive their own messages
	common.MessageSender

	common.RawMessageSender

	// NewMessenger needs a unique name; the caller must Close the Messenger.
	NewMessenger(name string) (Messenger, error)
}

MessageBus routes every message through one well-known Pubsub topic.

type Messenger added in v0.4.1

type Messenger interface {
	common.Named

	// Ch is closed by Close.
	Ch() <-chan entity.PubsubMessage

	// Send skips the Messenger itself and returns the pubsub publish error.
	Send(ctx context.Context, kind string, payload any) error

	Close()
}

Messenger is raw channel access to the bus, sender identity included.

type Meter added in v0.6.13

type Meter interface {
	common.Service

	// Provider is non-nil and fixed for the process lifetime, so instruments
	// may be created once and cached.
	Provider() metric.MeterProvider
}

Meter is the explicit metrics handle; framingo never uses the otel globals.

type Plan added in v0.8.1

type Plan interface {
	common.Service
	// Add copies the plan, which needs an ID, a kind and a Task with Schedule or
	// Manual; an ID taken on the task manager is a Conflict.
	Add(plan *entity.Plan) error
	// Trigger returns the run ID; empty source is InvalidArgument. The run always
	// ends with PlanRunFinished, without PlanRunStarted if dropped before starting.
	Trigger(id string, source entity.PlanRunSource) (string, error)
	// Cancel also drops a queued Trigger run, and keeps the plan.
	Cancel(id string) error
	// Delete waits for the run until ctx ends, then sends SignalKill and returns
	// an error wrapping ctx's; the returned run (nil if none) may then still be
	// running, its end reported as PlanRunFinished.
	Delete(ctx context.Context, id string) (*entity.PlanRun, error)
	// LastRun is nil if the plan has not run.
	LastRun(id string) (*entity.PlanRun, error)
	// OpenRunLog's file may still be written; tailBytes > 0 starts that far from
	// the end. A path outside the log dir is Forbidden, a missing one NotFound.
	OpenRunLog(path string, tailBytes int64) (io.ReadCloser, error)
	Stats(opts entity.PlanStatsOptions) ([]*entity.PlanStats, error)
}

type Pubsub

type Pubsub interface {
	common.Service

	// Publish skips subscribers named from. ctx bounds only cross-instance
	// delivery, so a cancel mid-publish can deliver partially.
	Publish(ctx context.Context, from, topic, kind string, payload any) error

	// Subscribe is hierarchical ("app" also gets "app/module"); callers must Unsubscribe.
	Subscribe(name, topic string) (<-chan entity.PubsubMessage, error)

	// Unsubscribe closes the channel.
	Unsubscribe(name, topic string) error
}

Pubsub is a bare channel transport; dispatch belongs on top, see MessageBus. A stop forgets every subscription, closing its channel, so a dependent that subscribes is a common.Reconcilable, and subscribes again.

type Supervisor added in v0.4.0

type Supervisor interface {
	common.Service
	// Register, before Init, also adds declared dependencies; re-registering an
	// instance is a no-op, a second instance under a taken name is a Conflict.
	Register(services ...common.Service) error
	TopoSort() error
	Services() []common.Service
	Stats() ([]*entity.SupervisorStats, error)
	// Migrate() error
	InitService(ctx context.Context, name string) error
	StartService(ctx context.Context, name string) error
	StopService(ctx context.Context, name string) error
	RestartService(ctx context.Context, name string) error
	Restart(ctx context.Context) error
}

type Task added in v0.8.1

type Task interface {
	common.Service
	// Add is all-or-nothing: no Job is InvalidArgument, a taken ID a Conflict.
	Add(tasks ...*entity.Task) error
	// Remove waits for executions until ctx ends, then sends SignalKill and
	// returns an error wrapping ctx's. It matches by job, not by ID.
	Remove(ctx context.Context, tasks ...*entity.Task) error
	Trigger(id string, params any) error
	Cancel(id string) error
	Stats(id string) *entity.TaskStats
}

Task holds runtime state alone: a stop forgets every task added, so a dependent that adds tasks is a common.Reconcilable, and adds them again.

type Tracer added in v0.6.11

type Tracer interface {
	common.Service

	// Provider is never nil (noop when off), and the tracing service's is the
	// same for its life: a restart swaps the pipeline under it, so it and a
	// Tracer from it may be kept.
	Provider() trace.TracerProvider

	Propagator() propagation.TextMapPropagator
}

Tracer is the explicit tracing handle; framingo never uses the otel globals.

Jump to

Keyboard shortcuts

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