presence

package
v1.0.0-rc.6 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: Apache-2.0 Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const DefaultHeartbeatInterval = DefaultTTL / 3
View Source
const DefaultInitialDelay = 1500 * time.Millisecond
View Source
const DefaultTTL = 30 * time.Second
View Source
const ReapMultiple = 3

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry struct {
	Record
	External bool `json:"external"`
	Stale    bool `json:"stale"`
}

type Kind

type Kind string
const (
	KindACP         Kind = "acp"
	KindVSCodeAgent Kind = "vscode-agent"
	KindServe       Kind = "serve"
)

type Record

type Record struct {
	InstanceID   string    `json:"instanceId"`
	Kind         Kind      `json:"kind"`
	PID          int       `json:"pid"`
	Host         string    `json:"host,omitempty"`
	StartedAt    time.Time `json:"startedAt"`
	LastSeen     time.Time `json:"lastSeen"`
	Cwd          string    `json:"cwd,omitempty"`
	Address      string    `json:"address,omitempty"`
	SessionCount int       `json:"sessionCount"`
	ClientName   string    `json:"clientName,omitempty"`
}

type Reporter

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

func StartReporter

func StartReporter(ctx context.Context, store ReporterStore, rec Record, opts ...ReporterOption) *Reporter

func (*Reporter) InstanceID

func (r *Reporter) InstanceID() string

func (*Reporter) Stop

func (r *Reporter) Stop()

func (*Reporter) Update

func (r *Reporter) Update(mutate func(rec *Record))

type ReporterOption

type ReporterOption func(*Reporter)

func WithInitialDelay

func WithInitialDelay(d time.Duration) ReporterOption

func WithInterval

func WithInterval(d time.Duration) ReporterOption

func WithLogger

func WithLogger(l *slog.Logger) ReporterOption

type ReporterStore

type ReporterStore interface {
	Register(ctx context.Context, rec Record) error
	Deregister(ctx context.Context, kind Kind, instanceID string) error
}

type Store

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

func NewStore

func NewStore(kv libkvstore.KVManager, opts ...StoreOption) *Store

func (*Store) Deregister

func (s *Store) Deregister(ctx context.Context, kind Kind, instanceID string) error

func (*Store) List

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

func (*Store) Register

func (s *Store) Register(ctx context.Context, rec Record) error

type StoreOption

type StoreOption func(*Store)

func WithClock

func WithClock(now func() time.Time) StoreOption

func WithHardTTL

func WithHardTTL(d time.Duration) StoreOption

func WithStaleTTL

func WithStaleTTL(d time.Duration) StoreOption

Jump to

Keyboard shortcuts

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