simulated

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package simulated is a compute backend that starts no compute.

It exists so a workload can be run through the real listener, allocator and placer at a scale no real backend can afford: a scenario with a thousand concurrent leases costs a thousand guests on every other backend, and nothing about a placement decision needs a guest to exist. An instance here is a record that reports itself running until a modelled duration has elapsed and stopped afterwards, and the duration comes from the spec rather than from anything this package decides, so the provider stays a mechanism and the workload stays the harness's business.

NONE OF THE CONTRACT IS WEAKENED FOR BEING A STAND-IN. List errors rather than answering short, because reconciliation frees the capacity of every lease absent from an inventory and a harness whose inventory may lie proves nothing about a scheduler that trusts it. Destroy reports TeardownStopped only for an instance this store held and removed. Untrusted work is refused, since there is no boundary here at all. Instances carry the deployment identity and destruction is scoped by it.

IT IS REFUSED IN A CONFIGURATION AND HAS NO PRODUCTION CALLER. config.Load rejects the kind wherever a file could name it and cmd/billet never constructs it; a test in this package proves nothing outside a test imports it. A backend that fabricates completions reachable from a real billet.yaml would be a fleet that reports every job finished and runs none.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunFor

func RunFor(d time.Duration) []string

RunFor renders the command a tier gives this backend: a runner that occupies its instance for d. It is the only shape Launch accepts.

Types

type Host

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

Host is the store instances live in: the machine, as far as this backend is concerned.

SHARED ON PURPOSE. Two deployments on one machine share a docker daemon, a tart store or a jailer root, and every backend has to keep them from seeing or destroying each other's compute. Two providers over one Host model that, and a provider built without one gets a Host of its own.

func NewHost

func NewHost() *Host

NewHost builds an empty host.

type Option

type Option func(*Provider)

Option configures a Provider.

func OnHost

func OnHost(h *Host) Option

OnHost places this provider's instances on a host it may share.

func WithClock

func WithClock(now func() time.Time) Option

WithClock replaces the clock instances are timed against. The default is time.Now; a harness replaces it so a modelled hour takes no wall time.

func WithLogger

func WithLogger(log *slog.Logger) Option

WithLogger sets the logger. The default is slog.Default().

type Provider

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

Provider is the simulated backend for one deployment.

func New

func New(owner string, opts ...Option) (*Provider, error)

New builds a simulated provider. owner names the deployment and is written onto every instance it starts.

func (*Provider) Accepts

func (p *Provider) Accepts(trust provider.TrustClass) error

Accepts refuses anything that is not established as trusted.

There is no boundary here at all: nothing runs, so nothing isolates. Unknown is refused alongside untrusted, because a caller that has not classified a job has not established it is safe anywhere.

func (*Provider) Destroy

func (p *Provider) Destroy(ctx context.Context, id string) (provider.Teardown, error)

Destroy removes an instance this deployment owns.

Idempotent: an id the host does not hold is success, and CONFIRMING, because this store is authoritative about its own contents the way the docker daemon is. An instance another deployment owns is refused rather than removed: the id came from somewhere, and destruction is scoped by identity.

func (*Provider) FailInventory

func (p *Provider) FailInventory(err error)

FailInventory makes List and Find answer err instead of the inventory until it is called again with nil.

THE HARNESS'S SEAM, and the only way an in-memory inventory can fail. A real backend loses its daemon or its API; what billet does then is the question, and a stand-in that cannot pose it proves nothing about the answer.

func (*Provider) Find

func (p *Provider) Find(ctx context.Context, name string) (*provider.Instance, bool, error)

Find reports this deployment's instance with that name, and whether there was one. The name is compared exactly.

func (*Provider) Kind

func (p *Provider) Kind() config.ProviderKind

Kind reports the backend this is.

func (*Provider) Launch

func (p *Provider) Launch(ctx context.Context, spec provider.Spec) (*provider.Instance, error)

Launch records one instance that will report itself running for the duration its command names.

func (*Provider) List

func (p *Provider) List(ctx context.Context) ([]*provider.Instance, error)

List reports every instance this deployment has on the host, running or not.

AN ERROR, NEVER A SHORT ANSWER. An inventory that cannot be read is reported as such, because the caller frees the capacity of every lease absent from what it is given.

Jump to

Keyboard shortcuts

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