Help us shape the future of Go! Take the 2026 Go Developer Survey

store

package
v1.3.104 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Overview

Package store pkg/deployment/sd/store/memory_store.go c4-net-discovery

Package store pkg/deployment/sd/store/redis_store.go c4-net-discovery

Package store pkg/deployment/sd/store/store.go c4-net-discovery

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MockStore

type MockStore struct {
	mock.Mock
}

MockStore is an autogenerated mock type for the Store type

func (*MockStore) Close

func (_m *MockStore) Close() error

Close provides a mock function with given fields:

func (*MockStore) CountServiceTypes

func (_m *MockStore) CountServiceTypes(ctx context.Context) (uint64, error)

CountServiceTypes provides a mock function with given fields: ctx

func (*MockStore) CountServices

func (_m *MockStore) CountServices(ctx context.Context, serviceType string) (uint64, error)

CountServices provides a mock function with given fields: ctx, serviceType

func (*MockStore) DeleteService

func (_m *MockStore) DeleteService(ctx context.Context, sType string, addr servicedisc.SWAddr) *servicedisc.HTTPError

DeleteService provides a mock function with given fields: ctx, sType, addr

func (*MockStore) GetAllVisorSummaries

func (_m *MockStore) GetAllVisorSummaries(ctx context.Context, v2 bool, timeline bool) ([]VisorSummary, error)

GetAllVisorSummaries provides a mock function with given fields: ctx, v2, timeline

func (*MockStore) GetDailyTimeline

func (_m *MockStore) GetDailyTimeline(ctx context.Context, pkHex string, now time.Time) map[string]string

GetDailyTimeline provides a mock function with given fields: ctx, pkHex, now

func (*MockStore) RecordHeartbeat

func (_m *MockStore) RecordHeartbeat(ctx context.Context, pk cipher.PubKey, version string) error

RecordHeartbeat provides a mock function with given fields: ctx, pk, version

func (*MockStore) Service

Service provides a mock function with given fields: ctx, sType, addr

func (*MockStore) Services

func (_m *MockStore) Services(ctx context.Context, sType, version, country string) ([]servicedisc.Service, *servicedisc.HTTPError)

Services provides a mock function with given fields: ctx, sType

func (*MockStore) ServicesByCountry

func (_m *MockStore) ServicesByCountry(ctx context.Context, sType string, sCountry string) ([]servicedisc.Service, *servicedisc.HTTPError)

ServicesByGeo provides a mock function with given fields: ctx, sType, q

func (*MockStore) ServicesByPK

func (_m *MockStore) ServicesByPK(ctx context.Context, pk cipher.PubKey) ([]servicedisc.Service, *servicedisc.HTTPError)

ServicesByPK provides a mock function with given fields: ctx, pk

func (*MockStore) UpdateService

func (_m *MockStore) UpdateService(ctx context.Context, se *servicedisc.Service) *servicedisc.HTTPError

UpdateService provides a mock function with given fields: ctx, se

func (*MockStore) UpdateServiceAndHeartbeat

func (_m *MockStore) UpdateServiceAndHeartbeat(ctx context.Context, se *servicedisc.Service, version string) *servicedisc.HTTPError

type Store

type Store interface {
	io.Closer
	Service(ctx context.Context, sType string, addr servicedisc.SWAddr) (*servicedisc.Service, *servicedisc.HTTPError)
	Services(ctx context.Context, sType, version, country string) ([]servicedisc.Service, *servicedisc.HTTPError)
	// ServicesByPK returns every service registration for a visor PK.
	// Used by the DHT mirror path so it can publish the visor's FULL
	// service list (vpn, skysocks, visor) under one DHT target rather
	// than overwriting the target with whichever type wrote last.
	ServicesByPK(ctx context.Context, pk cipher.PubKey) ([]servicedisc.Service, *servicedisc.HTTPError)
	UpdateService(ctx context.Context, se *servicedisc.Service) *servicedisc.HTTPError
	UpdateServiceAndHeartbeat(ctx context.Context, se *servicedisc.Service, version string) *servicedisc.HTTPError
	DeleteService(ctx context.Context, sType string, addr servicedisc.SWAddr) *servicedisc.HTTPError
	CountServiceTypes(ctx context.Context) (uint64, error)
	CountServices(ctx context.Context, serviceType string) (uint64, error)
	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
}

Store represents a DB implementation.

func NewMemoryStore added in v1.3.98

func NewMemoryStore(ttl time.Duration) Store

NewMemoryStore returns a Store kept in memory. ttl is how long an entry lives without an update; zero means entries never expire.

func NewStore

func NewStore(ctx context.Context, client *redis.Client, logger *logging.Logger, ttl time.Duration) (Store, error)

NewStore creates a new Redis store with TTL for service entries. The ttl parameter specifies how long service entries live before expiring. Services must send heartbeats before the TTL expires to stay registered.

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 for the SD /uptimes endpoint. v1: pk + online. v2 adds version + daily percentages. v3 adds timeline bitmaps.

Jump to

Keyboard shortcuts

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