contextdb

package
v0.0.0-...-7c77b90 Latest Latest
Warning

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

Go to latest
Published: May 27, 2022 License: Apache-2.0 Imports: 10 Imported by: 11

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitializeContextDatabase

func InitializeContextDatabase() error

InitializeContextDatabase sets up the connection to the configured database to allow the application to talk to it.

Types

type ContextDb

type ContextDb interface {
	// Returns nil if db health is good
	HealthCheck() error
	// Puts Json Struct in db with key
	Put(key string, value interface{}) error
	// Delete k,v
	Delete(key string) error
	// Delete all keys in heirarchy
	DeleteAll(key string) error
	// Gets Json Struct from db
	Get(key string, value interface{}) error
	// Returns all keys with a prefix
	GetAllKeys(path string) ([]string, error)
}

ContextDb is an interface for accessing the context database

var Db ContextDb

Db interface used to talk a concrete Database connection

func NewEtcdClient

func NewEtcdClient(store *clientv3.Client, c EtcdConfig) (ContextDb, error)

NewEtcdClient function initializes Etcd client

type Etcd

type Etcd interface {
	Put(ctx context.Context, key, val string, opts ...clientv3.OpOption) (*clientv3.PutResponse, error)
	Get(ctx context.Context, key string, opts ...clientv3.OpOption) (*clientv3.GetResponse, error)
	Delete(ctx context.Context, key string, opts ...clientv3.OpOption) (*clientv3.DeleteResponse, error)
}

Etcd For Mocking purposes

type EtcdClient

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

EtcdClient for Etcd

func (*EtcdClient) Delete

func (e *EtcdClient) Delete(key string) error

Delete values from Etcd DB

func (*EtcdClient) DeleteAll

func (e *EtcdClient) DeleteAll(key string) error

DeleteAll keys from Etcd DB

func (*EtcdClient) Get

func (e *EtcdClient) Get(key string, value interface{}) error

Get values from Etcd DB and decodes from json

func (*EtcdClient) GetAllKeys

func (e *EtcdClient) GetAllKeys(key string) ([]string, error)

GetAllKeys values from Etcd DB

func (*EtcdClient) HealthCheck

func (e *EtcdClient) HealthCheck() error

HealthCheck for checking health of the etcd cluster

func (*EtcdClient) Put

func (e *EtcdClient) Put(key string, value interface{}) error

Put values in Etcd DB

type EtcdConfig

type EtcdConfig struct {
	Endpoint string
	CertFile string
	KeyFile  string
	CAFile   string
}

EtcdConfig Configuration values needed for Etcd Client

type MockConDb

type MockConDb struct {
	Items []sync.Map
	sync.Mutex
	Err error
}

func (*MockConDb) Delete

func (c *MockConDb) Delete(key string) error

func (*MockConDb) DeleteAll

func (c *MockConDb) DeleteAll(key string) error

func (*MockConDb) Get

func (c *MockConDb) Get(key string, value interface{}) error

func (*MockConDb) GetAllKeys

func (c *MockConDb) GetAllKeys(path string) ([]string, error)

func (*MockConDb) HealthCheck

func (c *MockConDb) HealthCheck() error

func (*MockConDb) Put

func (c *MockConDb) Put(key string, value interface{}) error

Jump to

Keyboard shortcuts

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