reactor

package
v1.124.0 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Signal_End uint8 = iota
	Signal_IsUp
	Signal_IsFailed
	Signal_Cede
	Signal_CallTheInjectFunc
)
View Source
const (
	Status_Undef uint8 = iota
	Status_Fresh
	Status_Up
	Status_Failed
	Status_Ceded
	RequiredStatus_Up
	RequiredStatus_UpOrCeded
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Msg

type Msg struct {
	Signal     uint8
	Name       string                    // process node Id / OTDG name
	OTDG       upcommon.IRecursiveWindUp // the OTDG itself - can't use real type because of stupid Go language cycle import limitation
	InjectFunc func(r *Reactor)
}

type Options

type Options struct {
	ChUpSize int
}

type Reactor

type Reactor struct {
	Name          string // the name is required, since it's used in a user-side tracer when calling RecursiveWindUp()
	Context       context.Context
	Tracer        loggeterrapi.ITracer
	NeedsPattern  SubsystemsPattern // the required dependencies pattern, map[<dep_name>]<required_status>
	Func          func(r *Reactor, msg *Msg)
	Func_CanReact func(r *Reactor, msg *Msg, status *Status)

	Done bool
	// contains filtered or unexported fields
}

func NewReactor added in v1.89.0

func NewReactor(name string, ctx context.Context, tracer loggeterrapi.ITracer) *Reactor

func (*Reactor) CallTheInjectFunc added in v1.88.0

func (r *Reactor) CallTheInjectFunc(f func(r *Reactor))

func (*Reactor) End

func (r *Reactor) End()

Prefer not to use this when reactor achieves readiness - what if some will send up signals after the reactor already achieved readiness and closed? It will panic, and that's not what you may want. Use Done flag to make sure it reacts only once.

func (*Reactor) GetName added in v1.93.0

func (f *Reactor) GetName() string

func (*Reactor) GetStatus_InsideReactorFuncOnly added in v1.88.0

func (r *Reactor) GetStatus_InsideReactorFuncOnly() (s *Status)

Please: use only from within the reactor func

func (*Reactor) RecursiveWindUp added in v1.88.0

func (r *Reactor) RecursiveWindUp(tracer loggeterrapi.ITracer)

Be careful if your reactor dependency graph has diamond topology (is not a DAG); In that case, better implement explicit forward action plan to wind up your system.

func (*Reactor) Send

func (r *Reactor) Send(m *Msg)

func (*Reactor) SendStatus_Cede added in v1.88.0

func (r *Reactor) SendStatus_Cede(otdg upcommon.IRecursiveWindUp, name string)

func (*Reactor) SendStatus_Fail added in v1.88.0

func (r *Reactor) SendStatus_Fail(otdg upcommon.IRecursiveWindUp, name string)

func (*Reactor) SendStatus_Up added in v1.88.0

func (r *Reactor) SendStatus_Up(otdg upcommon.IRecursiveWindUp, name string)

func (*Reactor) StartFresh added in v1.88.0

func (r *Reactor) StartFresh(of ...func(opts *Options)) *Reactor

type Status

type Status struct {
	Fresh             []string
	Up                []string
	Ceded             []string
	NoFreshLeft       bool
	ReadinessAchieved bool
	CanReact          bool // it is set if ReadinessAchieved && !Done
}

type Subsystem added in v1.88.0

type Subsystem struct {
	Name   string
	Itself upcommon.IRecursiveWindUp
	Status uint8
}

type Subsystems added in v1.88.0

type Subsystems map[string]*Subsystem

type SubsystemsPattern added in v1.88.0

type SubsystemsPattern map[string]uint8 // the required dependencies pattern, map[<dep_name>]<required_status>

Jump to

Keyboard shortcuts

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