sessions

package
v0.1.27 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 2, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ContextProvider

type ContextProvider func() dbcontext.Context

type Options

type Options struct {
	Profiles ProfileStoreProvider
	Context  ContextProvider
	Registry *query.SessionRegistry
	Store    *Store
}

type ProfileStoreProvider

type ProfileStoreProvider func() (profiles.Store, error)

type Runner

type Runner struct {
	// contains filtered or unexported fields
}

func NewRunner

func NewRunner(options RunnerOptions) (*Runner, error)

func (*Runner) RunTop

func (r *Runner) RunTop(ctx context.Context, name string, options TopOptions) error

func (*Runner) RunTrace

func (r *Runner) RunTrace(ctx context.Context, name string, options TraceOptions) error

type RunnerOptions

type RunnerOptions struct {
	Profiles ProfileStoreProvider
	Context  ContextProvider
	Stdout   io.Writer
	Stderr   io.Writer
}

type Service

type Service struct {
	// contains filtered or unexported fields
}

func New

func New(options Options) (*Service, error)

func (*Service) Handler

func (s *Service) Handler(prefix string, next http.Handler) (http.Handler, error)

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store is the durable record of trace/top sessions: its OnTransition and OnEvent methods plug into query.RegistryOptions, upserting session state and batch-writing events. Live streaming always serves from memory; the DB answers after the session left the registry (restart, pruning).

func NewStore

func NewStore(db *gorm.DB, retention time.Duration) (*Store, error)

NewStore creates the store and starts its background flusher.

func (*Store) BindResolver

func (s *Store) BindResolver(resolve func(id string) (*query.Session, bool))

BindResolver wires the live-session lookup used to fail sessions whose events cannot be persisted.

func (*Store) Close

func (s *Store) Close() error

Close stops the background flusher after a final flush.

func (*Store) Events

func (s *Store) Events(ctx context.Context, id string) ([]query.Event, error)

Events returns the persisted events for a session, in sequence order.

func (*Store) Flush

func (s *Store) Flush() error

Flush writes all buffered events, joining any errors (including flush failures recorded for sessions with no live handle).

func (*Store) Get

func (s *Store) Get(ctx context.Context, id string) (query.SessionInfo, bool, error)

Get returns the persisted session, reporting absence without error.

func (*Store) List

func (s *Store) List(ctx context.Context) ([]query.SessionInfo, error)

List returns all persisted sessions, newest first.

func (*Store) MarkInterrupted

func (s *Store) MarkInterrupted(ctx context.Context) error

MarkInterrupted finalizes sessions orphaned by a restart: their streams are gone, so rows still starting/running become interrupted.

func (*Store) OnEvent

func (s *Store) OnEvent(e query.Event)

OnEvent buffers the event, flushing synchronously once a full batch has accumulated; it matches query.RegistryOptions.OnEvent.

func (*Store) OnTransition

func (s *Store) OnTransition(info query.SessionInfo)

OnTransition upserts the session row; it matches query.RegistryOptions.OnTransition.

func (*Store) Prune

func (s *Store) Prune(ctx context.Context) error

Prune atomically deletes terminal sessions older than the retention window and their events.

type TopOptions

type TopOptions struct {
	Interval string
	Duration string
	Params   []string
}

type TraceOptions

type TraceOptions struct {
	Duration string
	Params   []string
	Output   string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL