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 ¶
- func RunFor(d time.Duration) []string
- type Host
- type Option
- type Provider
- func (p *Provider) Accepts(trust provider.TrustClass) error
- func (p *Provider) Destroy(ctx context.Context, id string) (provider.Teardown, error)
- func (p *Provider) FailInventory(err error)
- func (p *Provider) Find(ctx context.Context, name string) (*provider.Instance, bool, error)
- func (p *Provider) Kind() config.ProviderKind
- func (p *Provider) Launch(ctx context.Context, spec provider.Spec) (*provider.Instance, error)
- func (p *Provider) List(ctx context.Context) ([]*provider.Instance, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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.
type Option ¶
type Option func(*Provider)
Option configures a Provider.
func WithClock ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
Launch records one instance that will report itself running for the duration its command names.