act

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: MIT Imports: 13 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

Overview

Package act is what a rule does: the Then of a Branch, every step said of whom it is done by or to, and the Branch itself, which given to a role is a rule.

act.Branch[Review]{
	Name: "escalate",
	When: cond.Self.If(overdue).And(cond.Self.If(cond.Not(escalated))),
	Then: act.Steps(act.Self.Put(escalated), act.Self.Do(Notify{To: "lead"})),
}

Steps

Self, Other and At are the subjects; their methods are the steps: Subject.Put, Subject.Take or Subject.Hold an effect, Subject.Do a command. Steps runs its parts in order, OneOf the first that does not fail; both take steps and branches.

Branches

A Branch at the top of a rule says its Name; every Branch says its When and its Then. It fires at its moment and is done within the pass. A rule turning to places (cond.At, At: the places its moment's host tells) runs once a place: the smallest part of it holding every clause of a place.

For package plan

A plan is made of what lasts over steps, in package plan, out of the same steps: every Step is a Lasting, and NewWait, NewIdle, NewLoop, LastingSteps, LastingOneOf and TopNode are the parts package plan builds on.

Index

Constants

This section is empty.

Variables

View Source
var (
	// Self is the entity the branch is about.
	Self = Subject{/* contains filtered or unexported fields */}
	// Other is the other of the pair the moment met, each of them, or the subject of the
	// moment or the fact; a step of it fails while there is none.
	Other = Subject{/* contains filtered or unexported fields */}
)

Functions

func TopNode added in v0.2.0

func TopNode(s Lasting) steps.Step

TopNode is root laid out as the top of a plan, each part at the top checked as one; for package plan.

Types

type Branch

type Branch[P any] struct {
	Name string    // required at the top of a rule
	When cond.Cond // required: cond.Self.If(cond.Always) for every time
	Then Step      // required
}

Branch is when what is done, every clause saying of whom: at the moment P a plugin's pass catches, or for P any on nothing but its When. Given to a role it is a rule; inside another branch's Then it asks more. In a plan it is a loop that ends with its steps.

func (Branch[P]) ForRole

func (b Branch[P]) ForRole(role cond.Role) Rule

ForRole is the rule narrowed to the players of role.

func (Branch[P]) Hosted

func (b Branch[P]) Hosted() any

Hosted is the branch built into the rule its moment's plugin runs, for the hosts (host.Hosted).

func (Branch[P]) Lasting

func (b Branch[P]) Lasting() Lasting

Lasting is the branch as a plan takes it.

func (Branch[P]) String

func (b Branch[P]) String() string

String is the branch's name and the type of its moment.

type Lasting

type Lasting interface {
	// contains filtered or unexported methods
}

Lasting is a step as a plan takes it: every Step, and what package plan makes of its own — steps that last over ticks, loops, groups of them.

func LastingOneOf

func LastingOneOf(parts ...Lasting) Lasting

LastingOneOf is OneOf of what a plan takes; for package plan.

func LastingSteps

func LastingSteps(parts ...Lasting) Lasting

LastingSteps is Steps of what a plan takes; for package plan.

func NewIdle

func NewIdle() Lasting

NewIdle is the entity doing nothing for ever; for package plan.

func NewLoop

func NewLoop[P any](name string, when cond.Cond, then Lasting, until cond.Cond,
	timeout, cooldown time.Duration) Lasting

NewLoop is a loop of a plan on the fact P (any for none): then run from the start as when comes to hold, ending well once until holds, failing after timeout, not beginning again within cooldown of its last run; for package plan.

func NewWait

func NewWait(d time.Duration) Lasting

NewWait is the entity doing nothing for d, then done well; for package plan.

type Rule

type Rule interface {
	fmt.Stringer
	// Hosted is the rule as its host runs it (host.Hosted).
	Hosted() any
	// ForRole is the rule narrowed to the players of role.
	ForRole(role cond.Role) Rule
}

Rule is what a role's players do at a moment a plugin catches: a Branch of that moment, or a role whose rules come with it. The moment's type says which plugin hosts it.

func Build

func Build(r Rule) Rule

Build is r as its host takes it: a Branch built, any other rule as it is. It panics where the branch cannot be built.

type Step

type Step interface {

	// Lasting is the step as a plan takes it (plan.Part).
	Lasting() Lasting
	// contains filtered or unexported methods
}

Step is a part of a rule's Then: a step said of somebody (Self.Do, Other.Put, At(p).Put), a group of them (Steps, OneOf) or a Branch. Every Step is a Lasting too: a plan takes it.

func OneOf

func OneOf(parts ...Step) Step

OneOf does as the first of its steps that does not fail, and fails when all fail.

func Steps

func Steps(parts ...Step) Step

Steps runs its steps one after another while each does well, and fails with the first that fails.

type Subject

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

Subject is whom a step is done by or to: Self, Other or At(places). Its methods are the steps.

func At added in v0.3.0

func At(places host.Places) Subject

At is each of the places its moment's host tells (host.Tick.Places), in a rule of a moment with them.

func (Subject) Do

func (s Subject) Do[C command.Command](cmd C) Step

Do gives the subject the command cmd and does well at once; a host.Aimed command is told the Subject of the moment or the fact, and fails while there is none. A command carrying ceremony.From is sent to the other as a message, a plan's alone. A command that names nobody panics here.

func (Subject) Hold

func (s Subject) Hold(e effect.Effect) Step

Hold holds the effect on the subject as long as the rule keeps firing, or in a plan as long as its loop runs; it fails when someone else takes the effect off.

func (Subject) Put

func (s Subject) Put(e effect.Effect) Step

Put puts the effect on the subject.

func (Subject) String

func (s Subject) String() string

String says whom.

func (Subject) Take

func (s Subject) Take(e effect.Effect) Step

Take takes the effect off the subject.

Jump to

Keyboard shortcuts

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