fakeengine

package
v0.5.4 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: Apache-2.0 Imports: 17 Imported by: 0 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 fakeengine is a lightweight engine for operator tests (0004 §9): it speaks the bundle protocol, verifies each bundle's signature and acknowledges it, without inspecting any traffic. Many fit in one test.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Engine

type Engine struct {
	ID string
	// Addr is the operator's distribution server, host:port.
	Addr string
	// TLS verifies the operator's certificate.
	TLS *tls.Config
	// Token is the ServiceAccount token sent as a bearer token.
	Token string
	// PublicKeys verify bundles, chosen by their key ID; SetPublicKeys
	// changes them while the engine runs, as a reloaded key file does.
	PublicKeys []ed25519.PublicKey
	// Reject, if set, decides whether to refuse a bundle (Nack).
	Reject func(*bundlev1.Bundle) error
	// Heartbeat is the interval of heartbeats; 0 means 1s.
	Heartbeat time.Duration
	// OnApply, if set, is called with each bundle the engine applies,
	// before its Ack.
	OnApply func(*bundlev1.Bundle)
	// KeepVersionOnly keeps only the version of the applied bundle, not
	// its policies: hundreds of engines with a large bundle each would
	// take gigabytes (the scale test, operator/test/scale).
	KeepVersionOnly bool
	// Shared, if set, is shared by the engines of one process: an engine
	// given the very bundle another one verified, byte for byte with the
	// same key, takes that one's result instead of decoding it again. The
	// bundle passed to Reject and OnApply, and kept, is then shared: read
	// only. Real engines each decode on their own CPU, at once; hundreds
	// of fake engines in one process decoding a 2 MB bundle at once took
	// gigabytes, and on a busy machine stalled long enough for the
	// operator to close their connections (the scale test, #296).
	Shared *Shared
	// contains filtered or unexported fields
}

Engine is a fake engine.

func (*Engine) Applied

func (e *Engine) Applied() *bundlev1.Bundle

Applied returns the bundle the engine runs, nil before the first.

func (*Engine) Err

func (e *Engine) Err() error

Err returns why the stream ended, once Run returned.

func (*Engine) Nacks added in v0.1.1

func (e *Engine) Nacks() int

Nacks returns how many bundles the engine rejected.

func (*Engine) Run

func (e *Engine) Run(ctx context.Context) error

Run connects and serves one stream until ctx ends or the stream fails.

func (*Engine) SetPublicKeys added in v0.1.1

func (e *Engine) SetPublicKeys(keys ...ed25519.PublicKey)

SetPublicKeys replaces the trusted keys; heartbeats report them.

func (*Engine) TrustedKeys added in v0.1.1

func (e *Engine) TrustedKeys() []string

TrustedKeys returns the IDs of the trusted keys.

type Shared added in v0.4.0

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

Shared is the bundle the engines of a process verified last; the zero value is ready.

Jump to

Keyboard shortcuts

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