Documentation
¶
Overview ¶
Package auditstream pushes the audit log to audit sinks as it is written (R-382, R-383, design 12 §5).
It runs on the leader alone (R-256): one delivering replica, so a destination never receives two interleaved copies of the stream. Sinks are built from their rows on every pass, as core/imageregistry builds registries, so a rotated token is what the next pass sends with on whichever replica leads, with no restart.
An adapter is handed encoded events and nothing else. This package reads the log through audit.Reader, which cannot write it (R-027), and records where each sink has got to in audit_sink_state.
Index ¶
- Constants
- func Describe(st Status) string
- type ConfigStore
- type CredentialStore
- type Declared
- type Notifier
- type Service
- func (s *Service) Holding(ctx context.Context, lo, hi time.Time) ([]string, error)
- func (s *Service) Pass(ctx context.Context) (bool, error)
- func (s *Service) Run(ctx context.Context)
- func (s *Service) Statuses(ctx context.Context) ([]Status, error)
- func (s *Service) Validate(ctx context.Context, id, kind string, config json.RawMessage, ...) error
- type Status
- type VerbHolders
Constants ¶
const DefaultBatch = 500
DefaultBatch is a batch's size when an adapter does not say.
const DefaultInterval = 2 * time.Second
DefaultInterval is how often a quiet pass runs. While any sink is behind, passes run back to back.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ConfigStore ¶
type ConfigStore interface {
List(ctx context.Context) ([]state.AdapterConfig, error)
}
ConfigStore lists stored adapters (state.Adapters).
type CredentialStore ¶
type CredentialStore interface {
Resolve(ctx context.Context, adapterID string) (map[string]secret.Value, error)
}
CredentialStore opens an adapter's sealed credentials (state.AdapterCredentials).
type Declared ¶
type Declared struct {
ID string
Adapter api.AuditSinkAdapter
}
Declared is an audit sink the startup configuration declares, already configured.
type Notifier ¶
type Notifier interface {
Notify(ctx context.Context, n api.Notification) error
}
Notifier sends Pando's own notifications.
type Service ¶
type Service struct {
Configs ConfigStore
Credentials CredentialStore
Declared []Declared
// New returns an unconfigured adapter of a kind, or nil.
New func(kind string) api.AuditSinkAdapter
States *state.AuditSinks
Reader *audit.Reader
// Encoders turn native lines into a sink's format. A format with no
// encoder — native — is sent as read.
Encoders map[string]audit.Encoder
// Audit writes the sink's own events: its first failure, its recovery,
// and Pando turning it off (R-383).
Audit func(ctx context.Context, e audit.Event)
Holders VerbHolders
Notifier Notifier
Clock clock.Clock
Logger *zap.Logger
Interval time.Duration
// contains filtered or unexported fields
}
Service delivers the audit log to every enabled audit sink.
func (*Service) Holding ¶
Holding names the enabled sinks that have not been sent every event in [lo, hi): the archiver keeps such a month in the live log (R-386). A sink Pando turned off does not hold.
func (*Service) Pass ¶
Pass sends one batch to every sink that is due. It reports whether any sink is still behind.
func (*Service) Run ¶
Run delivers until ctx ends: a pass every Interval while every sink is caught up, and back to back while any is behind.
func (*Service) Statuses ¶
Statuses lists every audit sink, enabled or not, with where it has got to.
func (*Service) Validate ¶
func (s *Service) Validate(ctx context.Context, id, kind string, config json.RawMessage, given map[string]secret.Value) error
Validate configures a sink as it would be saved — config and the credentials given, beside the ones already stored for id that are not replaced — and returns the adapter's refusal, so a sink Pando could not send with is refused when it is saved rather than at its first send. A credential sent empty removes the stored one, as saving does.
type Status ¶
type Status struct {
ID string `json:"id"`
Kind string `json:"kind"`
Name string `json:"name"`
Enabled bool `json:"enabled"`
Declared bool `json:"declared,omitempty"`
Transport string `json:"transport,omitempty"`
Endpoint string `json:"endpoint,omitempty"`
Format string `json:"format,omitempty"`
Actions []string `json:"actions,omitempty"`
Exclude []string `json:"exclude,omitempty"`
// Backlog is how many events are past the cursor, at most BacklogCap;
// BacklogCapped says there are at least that many.
Backlog int `json:"backlog"`
BacklogCapped bool `json:"backlog_capped,omitempty"`
// Unusable is why the sink cannot be built from its settings.
Unusable string `json:"unusable,omitempty"`
state.AuditSinkState
}
Status is one sink as the console, API, CLI and MCP show it (R-383, R-385).