Documentation
¶
Overview ¶
Package memory provides an in-memory implementation of the Chronicle store. It is intended for unit testing and development only.
Index ¶
- type Store
- func (s *Store) Accept(ctx context.Context, request acceptance.Request, h *hash.Chain, ...) (*acceptance.Receipt, error)
- func (s *Store) Aggregate(_ context.Context, q *audit.AggregateQuery) (*audit.AggregateResult, error)
- func (s *Store) Append(_ context.Context, event *audit.Event) error
- func (s *Store) AppendBatch(_ context.Context, events []*audit.Event) error
- func (s *Store) AppendCheckpoint(_ context.Context, cp *checkpoint.Checkpoint) error
- func (s *Store) AppendWithChain(ctx context.Context, e *audit.Event, h *hash.Chain) error
- func (s *Store) ByUser(_ context.Context, userID string, opts audit.TimeRange) (*audit.QueryResult, error)
- func (s *Store) CheckpointsInRange(_ context.Context, streamID id.ID, fromSeq, toSeq uint64) ([]*checkpoint.Checkpoint, error)
- func (s *Store) Close() error
- func (s *Store) CompleteErasure(_ context.Context, erasureID id.ID, o erasure.Outcome) error
- func (s *Store) Count(_ context.Context, q *audit.CountQuery) (int64, error)
- func (s *Store) CountBySubject(_ context.Context, sq erasure.SubjectQuery) (int64, error)
- func (s *Store) CountErasures(_ context.Context, sc erasure.Scope) (int64, error)
- func (s *Store) CreateStream(_ context.Context, st *stream.Stream) error
- func (s *Store) DeletePolicy(_ context.Context, policyID id.ID) error
- func (s *Store) DeleteReport(_ context.Context, reportID id.ID) error
- func (s *Store) EventRange(_ context.Context, streamID id.ID, fromSeq, toSeq uint64) ([]*audit.Event, error)
- func (s *Store) EventsOlderThan(_ context.Context, q retention.PurgeQuery) ([]*audit.Event, error)
- func (s *Store) Gaps(_ context.Context, streamID id.ID, fromSeq, toSeq uint64) ([]uint64, error)
- func (s *Store) Get(_ context.Context, eventID id.ID) (*audit.Event, error)
- func (s *Store) GetCheckpoint(_ context.Context, checkpointID id.ID) (*checkpoint.Checkpoint, error)
- func (s *Store) GetErasure(_ context.Context, erasureID id.ID) (*erasure.Erasure, error)
- func (s *Store) GetPolicy(_ context.Context, policyID id.ID) (*retention.Policy, error)
- func (s *Store) GetReport(_ context.Context, reportID id.ID) (*compliance.Report, error)
- func (s *Store) GetStream(_ context.Context, streamID id.ID) (*stream.Stream, error)
- func (s *Store) GetStreamByScope(_ context.Context, appID, tenantID string) (*stream.Stream, error)
- func (s *Store) LastHash(_ context.Context, streamID id.ID) (string, error)
- func (s *Store) LastSequence(_ context.Context, streamID id.ID) (uint64, error)
- func (s *Store) LatestCheckpoint(_ context.Context, streamID id.ID) (*checkpoint.Checkpoint, error)
- func (s *Store) ListArchives(_ context.Context, opts retention.ListOpts) ([]*retention.Archive, error)
- func (s *Store) ListCheckpoints(_ context.Context, streamID id.ID, opts checkpoint.ListOpts) ([]*checkpoint.Checkpoint, error)
- func (s *Store) ListErasures(_ context.Context, opts erasure.ListOpts) ([]*erasure.Erasure, error)
- func (s *Store) ListPolicies(_ context.Context, opts retention.ListPoliciesOpts) ([]*retention.Policy, error)
- func (s *Store) ListReports(_ context.Context, opts compliance.ListOpts) ([]*compliance.Report, error)
- func (s *Store) ListStreams(_ context.Context, opts stream.ListOpts) ([]*stream.Stream, error)
- func (s *Store) MarkErased(_ context.Context, sq erasure.SubjectQuery, erasureID id.ID) (int64, error)
- func (s *Store) Migrate(_ context.Context) error
- func (s *Store) Ping(_ context.Context) error
- func (s *Store) PurgeEvents(_ context.Context, eventIDs []id.ID) (int64, error)
- func (s *Store) Query(_ context.Context, q *audit.Query) (*audit.QueryResult, error)
- func (s *Store) RecordArchive(_ context.Context, a *retention.Archive) error
- func (s *Store) RecordErasure(_ context.Context, e *erasure.Erasure) error
- func (s *Store) SavePolicy(_ context.Context, p *retention.Policy) error
- func (s *Store) SaveReport(_ context.Context, r *compliance.Report) error
- func (s *Store) SubjectKeyUsage(_ context.Context, subjectID string) ([]erasure.KeyUsage, error)
- func (s *Store) UpdateStreamHead(_ context.Context, streamID id.ID, hash string, seq uint64) error
- func (s *Store) UpdateStreamScheme(_ context.Context, streamID id.ID, scheme string, since uint64) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is an in-memory implementation of all Chronicle store interfaces.
func (*Store) Accept ¶
func (s *Store) Accept(ctx context.Context, request acceptance.Request, h *hash.Chain, prepare func(*audit.Event) error) (*acceptance.Receipt, error)
Accept commits the event, stream and receipt under the shared store lock.
func (*Store) Aggregate ¶
func (s *Store) Aggregate(_ context.Context, q *audit.AggregateQuery) (*audit.AggregateResult, error)
Aggregate returns grouped counts/stats.
func (*Store) AppendBatch ¶
AppendBatch persists a batch of events atomically.
func (*Store) AppendCheckpoint ¶
func (s *Store) AppendCheckpoint(_ context.Context, cp *checkpoint.Checkpoint) error
AppendCheckpoint persists a checkpoint. Checkpoints are append-only: there is no update or delete, since a checkpoint that could be revised would assert nothing.
func (*Store) AppendWithChain ¶
AppendWithChain links a legacy event under the same lock as Accept.
func (*Store) ByUser ¶
func (s *Store) ByUser(_ context.Context, userID string, opts audit.TimeRange) (*audit.QueryResult, error)
ByUser returns events for a specific user within a time range.
func (*Store) CheckpointsInRange ¶
func (s *Store) CheckpointsInRange( _ context.Context, streamID id.ID, fromSeq, toSeq uint64, ) ([]*checkpoint.Checkpoint, error)
CheckpointsInRange returns every checkpoint whose range overlaps [fromSeq, toSeq], ascending by ToSeq.
Overlap rather than containment: a caller verifying sequences 150 to 160 still needs the checkpoint covering 101 to 200, because that is the one whose signed assertion those events fall under. Containment would silently return nothing for a range that sits inside a wider checkpoint.
func (*Store) CompleteErasure ¶
CompleteErasure writes an erasure's outcome and marks it completed. The stored record is replaced rather than edited, so a pointer GetErasure handed out earlier is never written under a reader.
func (*Store) CountBySubject ¶
CountBySubject returns the number of events for a subject within the query's scope.
func (*Store) CountErasures ¶
CountErasures returns the number of erasure records in the given scope.
func (*Store) CreateStream ¶
CreateStream initializes a new hash chain stream.
func (*Store) DeletePolicy ¶
DeletePolicy removes a retention policy.
func (*Store) DeleteReport ¶
DeleteReport removes a report.
func (*Store) EventRange ¶
func (s *Store) EventRange(_ context.Context, streamID id.ID, fromSeq, toSeq uint64) ([]*audit.Event, error)
EventRange returns events in a sequence range for chain verification.
func (*Store) EventsOlderThan ¶
EventsOlderThan returns the events the purge query selects, restricted to the query's scope.
func (*Store) GetCheckpoint ¶
func (s *Store) GetCheckpoint(_ context.Context, checkpointID id.ID) (*checkpoint.Checkpoint, error)
GetCheckpoint returns one checkpoint by ID.
func (*Store) GetErasure ¶
GetErasure returns an erasure record by ID.
func (*Store) GetStream ¶
GetStream returns a stream by ID (named to avoid collision with audit.Get).
func (*Store) GetStreamByScope ¶
GetStreamByScope returns the stream for a given app+tenant scope.
func (*Store) LastSequence ¶
LastSequence returns the highest sequence number for a stream.
func (*Store) LatestCheckpoint ¶
func (s *Store) LatestCheckpoint(_ context.Context, streamID id.ID) (*checkpoint.Checkpoint, error)
LatestCheckpoint returns the checkpoint with the highest ToSeq for a stream.
func (*Store) ListArchives ¶
func (s *Store) ListArchives(_ context.Context, opts retention.ListOpts) ([]*retention.Archive, error)
ListArchives returns archive records matching opts.
func (*Store) ListCheckpoints ¶
func (s *Store) ListCheckpoints( _ context.Context, streamID id.ID, opts checkpoint.ListOpts, ) ([]*checkpoint.Checkpoint, error)
ListCheckpoints returns a stream's checkpoints, newest first.
func (*Store) ListErasures ¶
ListErasures returns erasure records matching opts.
func (*Store) ListPolicies ¶
func (s *Store) ListPolicies(_ context.Context, opts retention.ListPoliciesOpts) ([]*retention.Policy, error)
ListPolicies returns retention policies matching opts.
func (*Store) ListReports ¶
func (s *Store) ListReports(_ context.Context, opts compliance.ListOpts) ([]*compliance.Report, error)
ListReports returns reports matching opts, scoped before pagination.
func (*Store) ListStreams ¶
ListStreams returns all streams.
func (*Store) MarkErased ¶
func (s *Store) MarkErased( _ context.Context, sq erasure.SubjectQuery, erasureID id.ID, ) (int64, error)
MarkErased flags a subject's events as erased within the query's scope. Events already marked are re-pointed at erasureID; see erasure.Store.
func (*Store) PurgeEvents ¶
PurgeEvents permanently deletes events by IDs.
func (*Store) RecordArchive ¶
RecordArchive records that a batch of events was archived.
func (*Store) RecordErasure ¶
RecordErasure persists an erasure event.
func (*Store) SavePolicy ¶
SavePolicy persists a retention policy, replacing any existing policy with the same ID or the same (app, tenant, category) scope.
func (*Store) SaveReport ¶
SaveReport persists a generated compliance report.
func (*Store) SubjectKeyUsage ¶
SubjectKeyUsage groups a subject's events across every scope by app, tenant, encryption key ID and erased flag. Unscoped on purpose; see erasure.Store.
func (*Store) UpdateStreamHead ¶
UpdateStreamHead updates the stream's head hash and sequence.