Documentation
¶
Index ¶
- Constants
- func KVOrphanedRecords() int64
- func LineageOf(records []query.SessionRecord, ids []string) map[string][]string
- func WithReadMemo(ctx context.Context) context.Context
- type KVResolver
- type KVStore
- func (s *KVStore) Begin(ctx context.Context, rec query.SessionRecord) error
- func (s *KVStore) Delete(ctx context.Context, id string) error
- func (s *KVStore) Get(ctx context.Context, id string) (query.SessionRecord, bool, error)
- func (s *KVStore) Lineage(ctx context.Context, ids []string) (map[string][]string, error)
- func (s *KVStore) List(ctx context.Context, filter query.SessionFilter) (query.SessionPage, error)
- func (s *KVStore) Update(ctx context.Context, id string, status query.SessionStatus) error
- type KVStoreOptions
- type Store
- func (s *Store) Append(_ context.Context, e query.Event) error
- func (s *Store) Begin(ctx context.Context, rec query.SessionRecord) error
- func (s *Store) BindResolver(resolve func(id string) (*query.Session, bool))
- func (s *Store) Close() error
- func (s *Store) CloseSession(_ context.Context, id string) error
- func (s *Store) Events(ctx context.Context, id string) ([]query.Event, error)
- func (s *Store) Flush() error
- func (s *Store) Get(ctx context.Context, id string) (query.SessionRecord, bool, error)
- func (s *Store) HasEvents(ctx context.Context, id string) (bool, error)
- func (s *Store) Lineage(ctx context.Context, ids []string) (map[string][]string, error)
- func (s *Store) List(ctx context.Context, filter query.SessionFilter) (query.SessionPage, error)
- func (s *Store) Prune(ctx context.Context) error
- func (s *Store) Update(ctx context.Context, id string, status query.SessionStatus) error
Constants ¶
const DefaultSessionTTL = 30 * 24 * time.Hour
DefaultSessionTTL is how long a kv session record lives from its start.
Variables ¶
This section is empty.
Functions ¶
func KVOrphanedRecords ¶
func KVOrphanedRecords() int64
KVOrphanedRecords counts the start records any KVStore in this process found without their status — evicted under maxmemory, say — and removed, with their index entries, rather than failing every list that reached them.
Types ¶
type KVResolver ¶
KVResolver names the cache a request's session records live in and the key prefix that isolates its environment (e.g. "oipa.lab:").
type KVStore ¶
type KVStore struct {
// contains filtered or unexported fields
}
KVStore is a query.SessionStore over a clicky cache.Store:
<prefix>sessions:v1:<id>:start immutable SessionStart JSON <prefix>sessions:v1:<id>:status SessionStatus JSON, expiry pinned to start <prefix>sessions:v1:index ZSET id → startedAt (unix ms)
func NewKVStore ¶
func NewKVStore(resolve KVResolver, options KVStoreOptions) (*KVStore, error)
NewKVStore stores records in the cache resolve names for each call; the cache is shared with every process using it.
func NewMemoryKVStore ¶
func NewMemoryKVStore(options KVStoreOptions) (*KVStore, error)
NewMemoryKVStore stores records in this process's memory for its lifetime.
func (*KVStore) Lineage ¶
Lineage reads only the records that could name ids: those started no earlier than the earliest of them, since a restart always starts after what it restarts.
func (*KVStore) List ¶
func (s *KVStore) List(ctx context.Context, filter query.SessionFilter) (query.SessionPage, error)
List reads every record in the filter's startedAt window (bounded by the ttl), dropping index entries whose start expired, then filters in Go.
type KVStoreOptions ¶
type KVStoreOptions struct {
// TTL is how long a record lives from its StartedAt; zero is
// DefaultSessionTTL.
TTL time.Duration
}
KVStoreOptions configures a KVStore.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is the database-backed query.SessionStore and query.EventSink of the query server: session records in the sessions table, and the events of capture stream sessions batch-written to session_events, which is what a session's events are replayed from after it left the registry.
func (*Store) Append ¶
Append buffers the event, flushing synchronously once a full batch has accumulated. It returns the failure of an earlier background flush of the session, so the session emitting it fails.
func (*Store) BindResolver ¶
BindResolver wires the live-session lookup used to fail sessions whose events cannot be persisted by the background flusher.
func (*Store) CloseSession ¶
CloseSession writes whatever the session still has buffered, along with any failure the background flusher recorded for it while it had no live handle. The registry calls it as the session ends, before its terminal status is written, so the record a reader finds is never ahead of the events table.
func (*Store) Flush ¶
Flush writes all buffered events, joining any errors (including flush failures recorded for sessions with no live handle).
func (*Store) HasEvents ¶
HasEvents reports whether any event of session id is buffered or persisted.
func (*Store) List ¶
func (s *Store) List(ctx context.Context, filter query.SessionFilter) (query.SessionPage, error)
List filters the scalar fields and the window in SQL, and authorizes by narrowing to the allowed profiles among those that match. Without a label filter SQL also counts, sorts and pages; labels live in the start JSON, so with one the matches are paged in Go.