storage

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Device

type Device struct {
	Owner     string    `json:"owner"`
	Name      string    `json:"name"`
	PublicKey string    `json:"publicKey"`
	Address   string    `json:"address"`
	CreatedAt time.Time `json:"createdAt"`

	// metadata about the device during the current session
	LastHandshakeTime *time.Time `json:"lastHandshakeTime"`
	ReceiveBytes      int64      `json:"receivedBytes"`
	TransmitBytes     int64      `json:"transmitBytes"`
	Endpoint          string     `json:"endpoint"`
}

type DiskStorage

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

implements Storage interface

func NewDiskStorage

func NewDiskStorage(directory string) *DiskStorage

func (*DiskStorage) Delete

func (s *DiskStorage) Delete(key string) error

func (*DiskStorage) Get

func (s *DiskStorage) Get(key string) (*Device, error)

func (*DiskStorage) List

func (s *DiskStorage) List(prefix string) ([]*Device, error)

func (*DiskStorage) Save

func (s *DiskStorage) Save(key string, device *Device) error

type InMemoryStorage

type InMemoryStorage struct{}

implements Storage interface

func NewMemoryStorage

func NewMemoryStorage() *InMemoryStorage

func (*InMemoryStorage) Delete

func (s *InMemoryStorage) Delete(key string) error

func (*InMemoryStorage) Get

func (s *InMemoryStorage) Get(key string) (*Device, error)

func (*InMemoryStorage) List

func (s *InMemoryStorage) List(prefix string) ([]*Device, error)

func (*InMemoryStorage) Save

func (s *InMemoryStorage) Save(key string, device *Device) error

type Storage

type Storage interface {
	Save(key string, device *Device) error
	List(prefix string) ([]*Device, error)
	Get(key string) (*Device, error)
	Delete(key string) error
}

Jump to

Keyboard shortcuts

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