storage

package
v0.0.0-...-c097f9c Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConsulClient

type ConsulClient struct {
	Client *api.Client
}

EtcdClient implements the Storage interface

func NewConsulClient

func NewConsulClient(addr string) (*ConsulClient, error)

NewConsulClient creates a new ConsulClient instance

func (*ConsulClient) Close

func (s *ConsulClient) Close() error

Close closes the etcd client

func (*ConsulClient) LoadTimestamp

func (s *ConsulClient) LoadTimestamp() (time.Time, error)

LoadTimestamp gets the timestamp

func (*ConsulClient) SaveTimestamp

func (s *ConsulClient) SaveTimestamp(ts time.Time) error

SaveTimestamp saves the timestamp

type EtcdClient

type EtcdClient struct {
	Client *clientv3.Client
}

EtcdClient implements the Storage interface

func (*EtcdClient) Close

func (s *EtcdClient) Close() error

Close closes the etcd client

func (*EtcdClient) LoadTimestamp

func (s *EtcdClient) LoadTimestamp() (time.Time, error)

LoadTimestamp gets the timestamp

func (*EtcdClient) SaveTimestamp

func (s *EtcdClient) SaveTimestamp(ts time.Time) error

SaveTimestamp saves the timestamp

type MemStorage

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

MemStorage is an in-memory implementation of the Storage interface

func (*MemStorage) Close

func (m *MemStorage) Close() error

Close closes the storage

func (*MemStorage) LoadTimestamp

func (m *MemStorage) LoadTimestamp() (time.Time, error)

LoadTimestamp loads the stored timestamp

func (*MemStorage) SaveTimestamp

func (m *MemStorage) SaveTimestamp(ts time.Time) error

SaveTimestamp stores a timestamp

type RedisClient

type RedisClient struct {
	Client *redis.Client
}

func NewRedisClient

func NewRedisClient(addr string) (*RedisClient, error)

NewRedisClient creates a new Redis client

func (*RedisClient) Close

func (r *RedisClient) Close() error

Close closes the Redis client connection

func (*RedisClient) LoadTimestamp

func (r *RedisClient) LoadTimestamp() (time.Time, error)

LoadTimestamp loads a timestamp from Redis

func (*RedisClient) SaveTimestamp

func (r *RedisClient) SaveTimestamp(ts time.Time) error

SaveTimestamp saves a timestamp to Redis

type Storage

type Storage interface {
	Close() error

	SaveTimestamp(ts time.Time) error
	LoadTimestamp() (time.Time, error)
}

func NewEtcdClient

func NewEtcdClient(endpoints []string, timeout time.Duration) (Storage, error)

NewEtcdClient creates a new EtcdClient instance

func NewMemStorage

func NewMemStorage() (Storage, error)

NewMemStorage creates a new instance of MemStorage

Jump to

Keyboard shortcuts

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