engine

package
v0.0.0-...-9a67539 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2025 License: MIT Imports: 10 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Identifier string
)

Functions

func Init

func Init()

Init only needs to be explicitly called if you need to run code before calling Run

func Run

func Run(units ...Unit)

Run assembles units and starts the program.

func Terminate

func Terminate()

Types

type Assembly

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

Assembly is a registry of related units.

func Assemble

func Assemble(units ...Unit) (asm *Assembly, err error)

func New

func New(v ...Unit) (*Assembly, error)

New returns an Assembly with any values added as units.

func (*Assembly) Add

func (a *Assembly) Add(v ...Unit) error

Add adds values to the assembly as units

func (*Assembly) Assemble

func (a *Assembly) Assemble(v interface{}) error

Assemble will set any fields on v that match a type or interface in the assembly. It only sets fields that are exported and unset. If there is more than one match for a field, the first one is used. If the field is a slice, it will be populated with all the matches for the slice element type.

func (*Assembly) AssignableTo

func (a *Assembly) AssignableTo(t reflect.Type) (u []Unit)

AssignableTo returns units that can be assigned to a value of the provided type. If the type is a slice/array, it returns units assignable to the element of the type.

func (*Assembly) Main

func (a *Assembly) Main() Unit

Main returns the first registered unit in the assembly. If there are no units it returns nil.

func (*Assembly) SelfAssemble

func (a *Assembly) SelfAssemble() error

SelfAssemble runs AssembleTo on the assembly units.

func (*Assembly) Units

func (a *Assembly) Units() []Unit

Units returns the units in the assembly.

func (*Assembly) ValueTo

func (a *Assembly) ValueTo(v interface{}) error

ValueTo sets a value to the first unit that matches the value type.

type Depender

type Depender interface {
	Assembly() []Unit
}

type Initializer

type Initializer interface {
	Initialize()
}

Initializer provides an initialization hook after assembly.

type PostInitializer

type PostInitializer interface {
	PostInitialize()
}

PostInitializer provides a hook after initialization.

type Runner

type Runner interface {
	Run(ctx context.Context) error
}

Runner is a unit that can take over the program entrypoint.

type Service

type Service interface {
	Serve(ctx context.Context)
}

Service is a long-running process managed by daemon.Framework.

type Terminator

type Terminator interface {
	Terminate()
}

type Unit

type Unit interface{}

Unit is a reference to a struct.

var (
	// Main is a global reference to the top-level main unit.
	Main Unit
)

func Dependencies

func Dependencies(units ...Unit) []Unit

Jump to

Keyboard shortcuts

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