world_control

package
v0.51.2 Latest Latest
Warning

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

Go to latest
Published: May 7, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecuteBusWatchLoop

func ExecuteBusWatchLoop(
	ctx context.Context,
	b bus.Bus,
	engineID string, write bool,
	objLoop *WatchLoop,
) error

ExecuteBusWatchLoop executes an existing WatchLoop with a Bus engine.

func WaitForObjectRev

func WaitForObjectRev(
	ctx context.Context,
	le *logrus.Entry,
	ws world.WorldState,
	objKey string,
	rev uint64,
) (world.ObjectState, error)

WaitForObjectRev waits for the object to exist equal at or greater than the given rev. If rev=0, waits for the object to exist at any rev.

Types

type WatchLoop

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

WatchLoop is a utility for building Controllers which bind to world state, running reconciliation loops until the world reaches a desired state.

func NewBusWatchLoop

func NewBusWatchLoop(
	ctx context.Context,
	le *logrus.Entry,
	b bus.Bus,
	engineID string, write bool,
	objectKey string, handler WatchLoopHandler,
) (*WatchLoop, *world.BusEngine, world.WorldState)

NewBusWatchLoop constructs a new BusEngine which attaches to an engine running on a controller bus.

func NewWatchLoop

func NewWatchLoop(
	le *logrus.Entry,
	objectKey string,
	handler WatchLoopHandler,
) *WatchLoop

NewWatchLoop constructs a new Control Loop which looks up an Engine on the Bus and calls the Callback when the state changes.

objectKey may be empty le may be nil

func (*WatchLoop) Execute

func (c *WatchLoop) Execute(ctx context.Context, ws world.WorldState) error

Execute runs the ControlLoop execution loop.

func (*WatchLoop) Wake

func (c *WatchLoop) Wake()

Wake forces the control loop to re-process the latest object state.

type WatchLoopHandler

type WatchLoopHandler = func(
	ctx context.Context,
	le *logrus.Entry,
	world world.WorldState,
	obj world.ObjectState,
	rootRef *bucket.ObjectRef,
	objRev uint64,
) (waitForChanges bool, err error)

WatchLoopHandler is the callback function for the WatchLoop. le may be nil

func NewWaitForStateHandler

func NewWaitForStateHandler(
	cb func(
		ctx context.Context,
		ws world.WorldState,

		obj world.ObjectState,
		rootCs *block.Cursor,
		rev uint64,
	) (bool, error),
) WatchLoopHandler

NewWaitForStateHandler constructs a WatchLoopHandler to wait for a state.

Jump to

Keyboard shortcuts

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