Documentation
¶
Overview ¶
Package primitive provides reusable data and processing primitives.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HandleProcess ¶
func HandleProcess(processes []Processable) error
HandleProcess runs processes in order and returns the first error encountered.
Types ¶
type Cache ¶
type Cache[T any] struct { // contains filtered or unexported fields }
Cache stores a lazily loaded value and the error produced while loading it. The cache is safe for concurrent reads, loading, updates, and resets.
func (*Cache[T]) IsLoaded ¶
IsLoaded reports whether the cache has completed loading or has been populated through Update.
func (*Cache[T]) Load ¶
Load calls loader once and stores both its value and error. A successful loader that returns a zero value still marks the cache as loaded.
func (*Cache[T]) ReportError ¶
ReportError invokes report once for the currently stored error. It is intended for compatibility wrappers that log an error while exposing a simpler value-only API.
func (*Cache[T]) Reset ¶
func (c *Cache[T]) Reset()
Reset clears the cached value, loading state, and stored errors.
type Datable ¶
type Datable struct {
CreatedAt time.Time `bun:"created_at,notnull,default:current_timestamp" bson:"createdAt" yaml:"createdAt" json:"createdAt"`
UpdatedAt time.Time `bun:"updated_at,notnull,default:current_timestamp" bson:"updatedAt" yaml:"updatedAt" json:"updatedAt"`
// contains filtered or unexported fields
}
Datable stores creation and update timestamps for a value.
func Dated ¶
func Dated() Datable
Dated returns a Datable whose update timestamp changes when touched.
func Steady ¶
func Steady() Datable
Steady returns a Datable whose update timestamp remains unchanged when touched.
func (*Datable) GetAge ¶
GetAge returns a copy of the Datable with the same timestamps and mutability.
func (*Datable) GetFormattedUpdated ¶
GetFormattedUpdated returns the last update timestamp formatted with format.
func (*Datable) GetcreatedAt ¶
GetcreatedAt returns the creation timestamp.
func (*Datable) GetupdatedAt ¶
GetupdatedAt returns the last update timestamp.
type Descriptible ¶
type Descriptible struct {
Name string `bun:"name" bson:"name" yaml:"name" json:"name"`
Description string `bun:"description" bson:"description" yaml:"description" json:"description"`
}
Descriptible stores a name and a description.
func Describe ¶
func Describe(params TemplateDescriptible) Descriptible
Describe returns a Descriptible initialized from params.
func (Descriptible) GetDescription ¶
func (d Descriptible) GetDescription() string
GetDescription returns the descriptive text.
func (Descriptible) GetName ¶
func (d Descriptible) GetName() string
GetName returns the descriptive name.
func (*Descriptible) SetDescription ¶
func (d *Descriptible) SetDescription(description string)
SetDescription replaces the descriptive text.
func (*Descriptible) SetName ¶
func (d *Descriptible) SetName(name string)
SetName replaces the descriptive name.
type Fallible ¶
type Fallible struct {
// contains filtered or unexported fields
}
Fallible collects errors produced while processing a value.
type FallibleInterface ¶
FallibleInterface describes values that collect and expose errors.
type Mill ¶
type Mill struct {
Fallible
}
Mill provides error collection for a processing component.
type Processable ¶
type Processable interface {
FallibleInterface
interfass.Runnable
}
Processable describes a runnable value that can report errors.
type ProcessableResult ¶
type ProcessableResult[T any] interface { Processable GetResult() T }
ProcessableResult describes a processable value that exposes a result.
type TemplateDatable ¶
type TemplateDatable struct {
Immutable bool
}
TemplateDatable configures the initial state of a Datable.
type TemplateDescriptible ¶
type TemplateDescriptible struct {
Name string //`bson:"name" json:"name" yaml:"name"`
Description string //`bson:"description" json:"description" yaml:"description"`
}
TemplateDescriptible contains the values used to create a Descriptible.