Documentation
¶
Overview ¶
Package clienttest provides an in-memory writer model implementing client.Hooks over a client.MemStore, for tests.
Index ¶
- Variables
- type Capture
- type Clock
- type Episode
- type StateQueryResult
- type Writer
- func (w *Writer) Apply(ops ...protocol.Op) (uint64, error)
- func (w *Writer) BundleAvailable(p protocol.BundleAvailableParams)
- func (w *Writer) Bundles() []protocol.BundleAvailableParams
- func (w *Writer) CaptureReplay(tx client.CaptureTx) (protocol.SummaryParams, error)
- func (w *Writer) Captures() []Capture
- func (w *Writer) Clone(store *client.MemStore) *Writer
- func (w *Writer) Episodes() map[string]Episode
- func (w *Writer) Fire(key string) (string, uint64, error)
- func (w *Writer) Health() any
- func (w *Writer) Rebaseline(tx client.CaptureTx) error
- func (w *Writer) Resolve(key string) (uint64, error)
- func (w *Writer) State() *protocol.State
- func (w *Writer) StateHashes(epoch protocol.EpochID) map[uint64]protocol.Hash
- func (w *Writer) Tool(_ context.Context, name string, args json.RawMessage) (any, error)
- func (w *Writer) Tools() []client.Tool
- func (w *Writer) Update(key string) (uint64, error)
Constants ¶
This section is empty.
Variables ¶
var ErrNoEpisode = errors.New("clienttest: no open episode")
ErrNoEpisode reports a transition for a key without an open episode.
Functions ¶
This section is empty.
Types ¶
type Capture ¶
type Capture struct {
Epoch protocol.EpochID
Watermark uint64
Committed uint64
AnchorHash protocol.Hash
Summary protocol.SummaryParams
}
Capture records one replay capture.
type Clock ¶
type Clock struct {
// contains filtered or unexported fields
}
Clock is a settable clock shared by a writer and its store.
type Episode ¶
type Episode struct {
ID string
DedupKey string
State string
FirstSeen uint64
LastTransition uint64
EvalTime uint64
Count uint64
Seq uint64
}
Episode is one finding episode.
type StateQueryResult ¶
type StateQueryResult struct {
Source string `json:"source"`
Resources []string `json:"resources"`
Truncated bool `json:"truncated"`
}
StateQueryResult is the state.query result.
type Writer ¶
type Writer struct {
Store *client.MemStore
Clock *Clock
// AnchorMutator, when set, alters the state written into replay anchors.
AnchorMutator func(*protocol.State)
// OnBundle, when set, is called for every bundle.available.
OnBundle func(protocol.BundleAvailableParams)
// contains filtered or unexported fields
}
Writer is the writer model. Every mutation runs inside Store.Do, so captures are atomic with it.
func (*Writer) BundleAvailable ¶
func (w *Writer) BundleAvailable(p protocol.BundleAvailableParams)
BundleAvailable records the announcement.
func (*Writer) Bundles ¶
func (w *Writer) Bundles() []protocol.BundleAvailableParams
Bundles returns every bundle announcement received.
func (*Writer) CaptureReplay ¶
CaptureReplay appends the replay anchor and returns the summary of findings touched above the committed head.
func (*Writer) Clone ¶
Clone copies the model onto store, as a restarted or forked process that rebuilt its state.
func (*Writer) Rebaseline ¶
Rebaseline appends the full checkpoint of a new epoch.
func (*Writer) StateHashes ¶
StateHashes returns the state hash at every sequence this writer assigned in epoch.