driver

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

type Database interface {
	Connect() error
	IsConnected() bool
	Put(key, value string) error
	PutWithLease(key, value string, leaseID clientv3.LeaseID) error
	Get(key string) (map[string]string, error)
	Delete(key string) (int64, error)
	CreateLease(seconds int64) (clientv3.LeaseID, error)
	RenewLease(leaseID clientv3.LeaseID) error
	GetKeys(key string) ([]string, error)
	Exists(key string) (bool, error)
	Close()
}

Database interface

func NewEtcdDriver

func NewEtcdDriver() Database

NewEtcdDriver create a new instance

type Etcd

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

Etcd driver

func (*Etcd) Close

func (e *Etcd) Close()

Close closes the etcd connection

func (*Etcd) Connect

func (e *Etcd) Connect() error

Connect connect to etcd server

func (*Etcd) CreateLease

func (e *Etcd) CreateLease(seconds int64) (clientv3.LeaseID, error)

CreateLease creates a lease

func (*Etcd) Delete

func (e *Etcd) Delete(key string) (int64, error)

Delete deletes a record

func (*Etcd) Exists

func (e *Etcd) Exists(key string) (bool, error)

Exists checks if a record exists

func (*Etcd) Get

func (e *Etcd) Get(key string) (map[string]string, error)

Get gets a record value

func (*Etcd) GetKeys

func (e *Etcd) GetKeys(key string) ([]string, error)

GetKeys gets a record sub keys This method will return only the keys under one key

func (*Etcd) IsConnected

func (e *Etcd) IsConnected() bool

IsConnected checks if there is an etcd connection

func (*Etcd) Put

func (e *Etcd) Put(key, value string) error

Put sets a record

func (*Etcd) PutWithLease

func (e *Etcd) PutWithLease(key, value string, leaseID clientv3.LeaseID) error

PutWithLease sets a record

func (*Etcd) RenewLease

func (e *Etcd) RenewLease(leaseID clientv3.LeaseID) error

RenewLease renews a lease

type EtcdMock

type EtcdMock struct {
	mock.Mock
}

EtcdMock type

func (*EtcdMock) Close

func (e *EtcdMock) Close()

Close mock

func (*EtcdMock) Connect

func (e *EtcdMock) Connect() error

Connect mock

func (*EtcdMock) CreateLease

func (e *EtcdMock) CreateLease(seconds int64) (clientv3.LeaseID, error)

CreateLease mock

func (*EtcdMock) Delete

func (e *EtcdMock) Delete(key string) (int64, error)

Delete mock

func (*EtcdMock) Exists

func (e *EtcdMock) Exists(key string) (bool, error)

Exists mock

func (*EtcdMock) Get

func (e *EtcdMock) Get(key string) (map[string]string, error)

Get mock

func (*EtcdMock) GetKeys

func (e *EtcdMock) GetKeys(key string) ([]string, error)

GetKeys mock

func (*EtcdMock) IsConnected

func (e *EtcdMock) IsConnected() bool

IsConnected mock

func (*EtcdMock) Put

func (e *EtcdMock) Put(key, value string) error

Put mock

func (*EtcdMock) PutWithLease

func (e *EtcdMock) PutWithLease(key, value string, leaseID clientv3.LeaseID) error

PutWithLease mock

func (*EtcdMock) RenewLease

func (e *EtcdMock) RenewLease(leaseID clientv3.LeaseID) error

RenewLease mock

Jump to

Keyboard shortcuts

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