actors

package
v0.6.76 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: AGPL-3.0, Apache-2.0, MIT Imports: 15 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 actors is the gateway's Substrate client (DBX-32): the actor lifecycle, egress policies, tags and worker drain state, on top of the vendored substrate.ateapi.v1 bindings in pkg/devbox/substrate/ateapi.

pkg/devbox/substrate (the operator's client) covers atespaces and templates; this package covers what only the gateway does. Every call is idempotent: creates return the existing object on AlreadyExists and deletes treat NotFound as success.

Index

Constants

View Source
const (
	// EgressPolicyName is the name of an actor's singleton egress policy.
	EgressPolicyName = "default"
)

Variables

View Source
var ErrCrashed = errors.New("actor crashed")

ErrCrashed is returned by WaitState when the actor crashed while waiting.

Functions

func EgressRules

func EgressRules(p egress.Policy) []*ateapi.EgressRule

EgressRules converts an egress policy to Substrate rules.

func TagFidelity

func TagFidelity(t *ateapi.Tag) ateapi.SnapshotFidelity

TagFidelity reports whether a tag holds memory or only filesystem state.

Types

type Client

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

Client wraps substrate.ateapi.v1.Control.

func Dial

func Dial(cfg substrate.Config) (*Client, error)

Dial connects to ate-api-server like substrate.Dial: TLS with the servicedns CA bundle, plus the projected ServiceAccount token re-read on every call.

func New

func New(control ateapi.ControlClient) *Client

New wraps an existing Control client.

func (*Client) ApplyEgressPolicy

func (c *Client) ApplyEgressPolicy(ctx context.Context, ref Ref, rules []*ateapi.EgressRule) error

ApplyEgressPolicy creates or replaces an actor's egress policy.

func (*Client) Close

func (c *Client) Close() error

func (*Client) CreateActor

func (c *Client) CreateActor(ctx context.Context, spec Spec) (*ateapi.Actor, error)

CreateActor creates a suspended actor, or returns the existing one.

func (*Client) CreateTag

func (c *Client) CreateTag(ctx context.Context, tag Ref, source Ref) (*ateapi.Tag, error)

CreateTag tags a suspended actor's latest snapshot, or returns the existing tag.

func (*Client) DeleteActor

func (c *Client) DeleteActor(ctx context.Context, ref Ref) error

DeleteActor deletes an actor and its egress policy.

func (*Client) DeleteEgressPolicy

func (c *Client) DeleteEgressPolicy(ctx context.Context, ref Ref) error

func (*Client) DeleteTag

func (c *Client) DeleteTag(ctx context.Context, tag Ref) error

func (*Client) DrainingWorkers

func (c *Client) DrainingWorkers(ctx context.Context) (map[string]bool, error)

DrainingWorkers returns the names of workers being drained: their actors get SIGTERM and must be suspended synchronously within the drain window.

func (*Client) GetActor

func (c *Client) GetActor(ctx context.Context, ref Ref) (*ateapi.Actor, error)

func (*Client) GetTag

func (c *Client) GetTag(ctx context.Context, tag Ref) (*ateapi.Tag, error)

func (*Client) ListActors

func (c *Client) ListActors(ctx context.Context, atespace string) ([]*ateapi.Actor, error)

ListActors returns every actor in an atespace.

func (*Client) Resume

func (c *Client) Resume(ctx context.Context, ref Ref) error

Resume resumes an actor. It returns once Substrate accepted the request; WaitState waits for RUNNING.

func (*Client) Revert

func (c *Client) Revert(ctx context.Context, ref Ref) error

Revert returns a crashed actor to its last good snapshot (suspended).

func (*Client) SetTemplate

func (c *Client) SetTemplate(ctx context.Context, ref Ref, template string) error

SetTemplate points a (suspended) actor at another template; its next resume restores volume data and cold-boots (filesystem fidelity).

func (*Client) Suspend

func (c *Client) Suspend(ctx context.Context, ref Ref, synchronous bool) error

Suspend suspends an actor. Synchronous suspends return once the snapshot is durable (needed before eviction and tagging); asynchronous ones once the actor is suspended locally.

func (*Client) WaitState

func (c *Client) WaitState(ctx context.Context, ref Ref, states ...ateapi.ActorState) (*ateapi.Actor, error)

WaitState polls until the actor reaches one of the states. A crash ends the wait with ErrCrashed unless CRASHED is one of the states.

func (*Client) WaitTag

func (c *Client) WaitTag(ctx context.Context, tag Ref) (*ateapi.Tag, error)

WaitTag polls until the tag's snapshot copy completed.

func (*Client) WithPollInterval

func (c *Client) WithPollInterval(d time.Duration) *Client

WithPollInterval sets how often the Wait* helpers poll; tests shorten it.

type Ref

type Ref struct {
	Atespace string
	Name     string
}

Ref names an actor or tag.

func ParseRef

func ParseRef(s, defaultAtespace string) Ref

ParseRef parses "<atespace>/<name>", the actor ID format egress uses. A bare name takes defaultAtespace.

func (Ref) String

func (r Ref) String() string

type Spec

type Spec struct {
	Ref Ref
	// Template is the ActorTemplate name, in Ref.Atespace.
	Template string
	// SourceTag seeds the actor's first resume from a tag (golden or snapshot), in Ref.Atespace.
	SourceTag string
}

Spec describes an actor to create.

Directories

Path Synopsis
Package actorstest is an in-memory substrate.ateapi.v1.Control server for gateway tests.
Package actorstest is an in-memory substrate.ateapi.v1.Control server for gateway tests.

Jump to

Keyboard shortcuts

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