Documentation
¶
Overview ¶
Package storage keeps the states that mirrors report to the SPECTRE server. A URL selects the backend by its scheme, such as memory://, redis://, or redis-cluster://.
Index ¶
- type Config
- type Constructor
- type Memory
- func (m *Memory) Clear(_ context.Context, service, environment string, at time.Time) error
- func (m *Memory) Close() error
- func (m *Memory) Divergences(_ context.Context) ([]model.Divergence, error)
- func (m *Memory) Put(_ context.Context, state model.State, at time.Time) error
- func (m *Memory) Record(_ context.Context, divergence model.Divergence) error
- func (m *Memory) States(_ context.Context, since time.Time) ([]model.State, error)
- type Redis
- func (r *Redis) Clear(ctx context.Context, service, environment string, at time.Time) error
- func (r *Redis) Close() error
- func (r *Redis) Divergences(ctx context.Context) ([]model.Divergence, error)
- func (r *Redis) Put(ctx context.Context, state model.State, at time.Time) error
- func (r *Redis) Record(ctx context.Context, divergence model.Divergence) error
- func (r *Redis) States(ctx context.Context, since time.Time) ([]model.State, error)
- type Store
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Constructor ¶ added in v0.41.0
Constructor opens a store at a URL whose scheme it is registered for.
type Memory ¶
type Memory struct {
// contains filtered or unexported fields
}
Memory keeps states in memory, so a restart loses them. Stored states share their maps with callers, who never mutate them.
func (*Memory) Clear ¶
Clear removes the divergences of a service environment's mirror, and ignores its quarantines that began before at.
func (*Memory) Divergences ¶ added in v0.47.0
Divergences returns every stored divergence, in no particular order.
type Redis ¶
type Redis struct {
// contains filtered or unexported fields
}
Redis keeps states and divergences in two hashes, shared by servers using the same database. Each command touches one key, so it works in a cluster.
func NewRedis ¶
NewRedis connects to the Redis server at a redis:// or rediss:// URL, or to the Redis Cluster at a redis-cluster:// or rediss-cluster:// URL.
func (*Redis) Clear ¶
Clear removes the divergences of a service environment's mirror, and ignores its quarantines that began before at.
func (*Redis) Divergences ¶ added in v0.47.0
Divergences returns every stored divergence, in no particular order.
type Store ¶
type Store interface {
// Put replaces the state of a service environment's mirror.
Put(ctx context.Context, state model.State, received time.Time) error
// States returns the states received at or after since, in no particular
// order, and forgets older ones.
States(ctx context.Context, since time.Time) ([]model.State, error)
// Record keeps a divergence unless its source has already reported a later
// quarantine, or its service environment was cleared after it began.
Record(ctx context.Context, divergence model.Divergence) error
// Clear removes the divergences of a service environment's mirror, and
// ignores its quarantines that began before at.
Clear(ctx context.Context, service, environment string, at time.Time) error
// Divergences returns every stored divergence, in no particular order.
Divergences(ctx context.Context) ([]model.Divergence, error)
Close() error
}
Store keeps the latest state of each service environment's mirror, with when the server received it. Callers validate states and never mutate stored ones.