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

store

package
v1.3.98 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2026 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

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

Package store pkg/deployment/ut/store/postgres_store.go c4-net-discovery

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

Package store pkg/deployment/ut/store/uptime_response.go c4-net-discovery

Package store pkg/deployment/ut/store/visors_response.go c4-net-discovery

Index

Constants

View Source
const OnlineThreshold = time.Minute * 6

OnlineThreshold is a value used for uptime calculation.

View Source
const (
	// UptimeSeconds is a time (in seconds) that for each update request from visor will added to its uptime value
	UptimeSeconds = 300
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DailyUptimeHistory

type DailyUptimeHistory struct {
	ID          uint `gorm:"primarykey" json:"-"`
	CreatedAt   time.Time
	UpdatedAt   time.Time
	PubKey      string
	DailyOnline int
	Version     string
	IPs         string
	LastIP      string
}

DailyUptimeHistory is gorm.Model for daily uptime history table

type Store

type Store interface {
	GetAllUptimes(startYear int, startMonth time.Month, endYear int, endMonth time.Month) (UptimeResponse, error)
	GetUptimes(pubKeys []string, startYear int, startMonth time.Month, endYear int, endMonth time.Month) (UptimeResponse, error)
	GetAllVisors(locDetails geo.LocationDetails) (VisorsResponse, error)
	GetVisorsIPs(month string) (map[string]visorIPsResponse, error)
	GetNumberOfUptimesInCurrentMonth() (int, error)
	GetNumberOfUptimesByYearAndMonth(year int, month time.Month) (int, error)
	UpdateUptime(pk, ip, version string) error
	GetDailyUpdateHistory() (map[string]map[string]string, error)
	DeleteEntries([]DailyUptimeHistory) error
	GetOldestEntry() (DailyUptimeHistory, error)
	GetSpecificDayData(time time.Time) ([]DailyUptimeHistory, error)
	Close()
}

Store is a wrapper for `UptimeStore`.

func New

func New(logger *logging.Logger, gormDB *gorm.DB, testing bool) (Store, error)

New constructs a new Store of requested type.

func NewMemoryStore

func NewMemoryStore() Store

NewMemoryStore creates new uptimes memory store.

func NewPostgresStore

func NewPostgresStore(logger *logging.Logger, cl *gorm.DB) (Store, error)

NewPostgresStore creates new uptimes postgres store.

type UptimeDef

type UptimeDef struct {
	Key     string `json:"key"`
	Online  bool   `json:"online"`
	Version string `json:"-"`
}

UptimeDef is the item of `UptimeResponse`.

type UptimeDefV2

type UptimeDefV2 struct {
	Key                string            `json:"pk"`
	Online             bool              `json:"on"`
	Version            string            `json:"version,omitempty"`
	DailyOnlineHistory map[string]string `json:"daily,omitempty"`
}

UptimeDefV2 is the item of `UptimeResponseV2`.

type UptimeResponse

type UptimeResponse []UptimeDef

UptimeResponse is the tracker API response format for `/uptimes`.

type UptimeResponseV2

type UptimeResponseV2 []UptimeDefV2

UptimeResponseV2 is the tracker API response format v2 for `/uptimes`.

type VisorDef

type VisorDef struct {
	Lat float64 `json:"lat"`
	Lon float64 `json:"lon"`
}

VisorDef is the item of `VisorsResponse`.

type VisorsResponse

type VisorsResponse []VisorDef

VisorsResponse is the tracker API response format for `/visors`.

Jump to

Keyboard shortcuts

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