Documentation
¶
Overview ¶
Package store pkg/dmsg/discovery/store/entry_cache.go c1-net-dmsg
Package store pkg/dmsg/discovery/store/redis.go c1-net-dmsg
Package store pkg/dmsg/discovery/store/storer.go c1-net-dmsg
Package store pkg/dmsg/discovery/store/testing.go c1-net-dmsg
Index ¶
- Constants
- Variables
- type Config
- type EntryEnumerator
- type EntryStore
- type MockStore
- func (ms *MockStore) AllClientEntries(_ context.Context) ([]*disc.Entry, error)
- func (ms *MockStore) AllEntries(_ context.Context) ([]string, error)
- func (ms *MockStore) AllServers(_ context.Context) ([]*disc.Entry, error)
- func (ms *MockStore) AllVisorEntries(_ context.Context) ([]string, error)
- func (ms *MockStore) AvailableServers(_ context.Context, _ int) ([]*disc.Entry, error)
- func (ms *MockStore) Clear()
- func (ms *MockStore) CountEntries(_ context.Context) (int64, int64, error)
- func (ms *MockStore) DelEntry(_ context.Context, staticPubKey cipher.PubKey) error
- func (ms *MockStore) Entry(_ context.Context, staticPubKey cipher.PubKey) (*disc.Entry, error)
- func (ms *MockStore) GetAllVisorSummaries(_ context.Context, _ bool, _ bool) ([]VisorSummary, error)
- func (ms *MockStore) GetDailyTimeline(_ context.Context, _ string, _ time.Time) map[string]string
- func (ms *MockStore) RecordHeartbeat(_ context.Context, _ cipher.PubKey, _ string) error
- func (ms *MockStore) RemoveOldServerEntries(_ context.Context) error
- func (ms *MockStore) RemoveStaleClientEntries(_ context.Context, _ time.Duration) (int, int, error)
- func (ms *MockStore) SetEntry(_ context.Context, entry *disc.Entry, _ time.Duration) error
- type ServerLister
- type Storer
- type UptimeTracker
- type VisorSummary
Constants ¶
const ( DefaultURL = "redis://localhost:6379" DefaultTimeout = time.Minute * 3 )
Config defaults.
Variables ¶
var ( // ErrTooFewArgs is returned on attempt to create a Redis store without passing its URL. ErrTooFewArgs = errors.New("too few args") )
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
URL string // database URI
Password string // database password
Timeout time.Duration // database entry timeout (0 == none)
PoolSize int // redis connection pool size (0 == the client default)
}
Config configures the Store object.
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns a config with default values.
type EntryEnumerator ¶
type EntryEnumerator interface {
// CountEntries returns numbers of servers and clients.
CountEntries(ctx context.Context) (int64, int64, error)
// AllEntries returns all clients PKs.
AllEntries(ctx context.Context) ([]string, error)
// AllVisorEntries returns all clients PKs.
AllVisorEntries(ctx context.Context) ([]string, error)
// AllClientEntries returns all full client entries.
AllClientEntries(ctx context.Context) ([]*disc.Entry, error)
}
EntryEnumerator provides bulk entry access.
type EntryStore ¶
type EntryStore interface {
// Entry obtains a single dmsg instance entry.
Entry(ctx context.Context, staticPubKey cipher.PubKey) (*disc.Entry, error)
// SetEntry set's an entry.
// This is unsafe and does not check signature.
SetEntry(ctx context.Context, entry *disc.Entry, timeout time.Duration) error
// DelEntry delete's an entry.
DelEntry(ctx context.Context, staticPubKey cipher.PubKey) error
}
EntryStore provides basic CRUD for discovery entries.
type MockStore ¶
type MockStore struct {
// contains filtered or unexported fields
}
MockStore implements a storer mock
func (*MockStore) AllClientEntries ¶
AllClientEntries implements Storer AllClientEntries method for MockStore
func (*MockStore) AllEntries ¶
AllEntries implements Storer CountEntries method for MockStore
func (*MockStore) AllServers ¶
AllServers implements Storer AllServers method for MockStore
func (*MockStore) AllVisorEntries ¶
AllVisorEntries implements Storer CountEntries method for MockStore
func (*MockStore) AvailableServers ¶
AvailableServers implements Storer AvailableServers method for MockStore
func (*MockStore) Clear ¶
func (ms *MockStore) Clear()
Clear its a mock-only method to clear the mock store data
func (*MockStore) CountEntries ¶
CountEntries implements Storer CountEntries method for MockStore
func (*MockStore) GetAllVisorSummaries ¶
func (*MockStore) GetDailyTimeline ¶
func (*MockStore) RecordHeartbeat ¶
func (*MockStore) RemoveOldServerEntries ¶
RemoveOldServerEntries implements Storer RemoveOldServerEntries method for MockStore
func (*MockStore) RemoveStaleClientEntries ¶
RemoveStaleClientEntries implements Storer for MockStore (no-op).
type ServerLister ¶
type ServerLister interface {
// AvailableServers discovers available dmsg servers.
AvailableServers(ctx context.Context, maxCount int) ([]*disc.Entry, error)
// AllServers discovers available dmsg servers.
AllServers(ctx context.Context) ([]*disc.Entry, error)
}
ServerLister provides server enumeration.
type Storer ¶
type Storer interface {
EntryStore
ServerLister
EntryEnumerator
UptimeTracker
// RemoveOldServerEntries check and remove old server entries that left on redis because of unexpected server shutdown
RemoveOldServerEntries(ctx context.Context) error
// RemoveStaleClientEntries removes client entries with expired keys from the
// "clients" set and applies defaultTTL to legacy entries that have no expiration.
RemoveStaleClientEntries(ctx context.Context, defaultTTL time.Duration) (removed, ttlSet int, err error)
}
Storer is an interface which allows to implement different kinds of stores and choose which one to use in the server
type UptimeTracker ¶
type UptimeTracker interface {
RecordHeartbeat(ctx context.Context, pk cipher.PubKey, version string) error
GetAllVisorSummaries(ctx context.Context, v2 bool, timeline bool) ([]VisorSummary, error)
GetDailyTimeline(ctx context.Context, pkHex string, now time.Time) map[string]string
}
UptimeTracker provides integrated uptime tracking for dmsg entries.
type VisorSummary ¶
type VisorSummary struct {
PK cipher.PubKey `json:"pk"`
Online bool `json:"on"`
Version string `json:"version,omitempty"`
Daily map[string]string `json:"daily,omitempty"`
Timeline map[string]string `json:"timeline,omitempty"`
}
VisorSummary holds a visor's uptime data. Format matches the TPD and uptime tracker response.