storage

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FavoriteFileSuffix = ".favorite-node.json"
	AvoidFileSuffix    = ".avoid-node.json"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AvoidNode

type AvoidNode struct {
	IP        string `json:"ip"`
	MaskSize  int32  `json:"maskSize"`
	Address   string `json:"address"`
	ExpiresAt int64  `json:"expiredAt"`
}

type AvoidNodes

type AvoidNodes = map[string]*AvoidNode

type FavoriteNode

type FavoriteNode struct {
	IP           string  `json:"ip"`
	Address      string  `json:"address"`
	Metadata     string  `json:"metadata"`
	Delay        float32 `json:"delay"`
	MinBandwidth float32 `json:"minBandwidth"`
	MaxBandwidth float32 `json:"maxBandwidth"`
	ExpiresAt    int64   `json:"expiredAt"`
}

type MeasureStorage

type MeasureStorage struct {
	FavoriteNodes *Storage

	AvoidNodes map[string]AvoidNodes
	// contains filtered or unexported fields
}

func NewMeasureStorage

func NewMeasureStorage(path, filenamePrefix string) *MeasureStorage

func (*MeasureStorage) AddAvoidNode

func (s *MeasureStorage) AddAvoidNode(key string, val *AvoidNode)

func (*MeasureStorage) AddFavoriteNode

func (s *MeasureStorage) AddFavoriteNode(key string, val *FavoriteNode) bool

func (*MeasureStorage) ClearAvoidExpired

func (s *MeasureStorage) ClearAvoidExpired() error

func (*MeasureStorage) ClearFavoriteExpired

func (s *MeasureStorage) ClearFavoriteExpired() error

func (*MeasureStorage) GetAvoidCIDR

func (s *MeasureStorage) GetAvoidCIDR() []*net.IPNet

func (*MeasureStorage) Load

func (s *MeasureStorage) Load() error

Load must be called before all other methods

func (*MeasureStorage) SaveAvoidNodes

func (s *MeasureStorage) SaveAvoidNodes() error

func (*MeasureStorage) SaveFavoriteNodes

func (s *MeasureStorage) SaveFavoriteNodes() error

type Storage

type Storage struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewStorage

func NewStorage() *Storage

func (*Storage) Add

func (s *Storage) Add(key string, val interface{})

func (*Storage) Delete

func (s *Storage) Delete(key string)

func (*Storage) Get

func (s *Storage) Get(key string) (interface{}, bool)

func (*Storage) GetData

func (s *Storage) GetData() map[string]interface{}

func (*Storage) Len

func (s *Storage) Len() int

Jump to

Keyboard shortcuts

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