etcd

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrorCodeKeyConflict = 409
	ErrorCodeKeyNotFound = 404
)

Variables

This section is empty.

Functions

func IsKeyConflict

func IsKeyConflict(err error) bool

IsKeyConflict returns true if the error code is ErrorCodeKeyConflict.

func IsKeyNotFound

func IsKeyNotFound(err error) bool

IsKeyNotFound returns true if the error code is ErrorCodeKeyNotFound.

Types

type DAO

type DAO interface {
	io.Closer
	Create(key string, entity interface{}) error
	Upsert(key string, entity interface{}) error
	Get(key string, entity interface{}) error
	Query(query Query, slice interface{}) error
	Delete(key string) error
	Watch(ctx context.Context, query Query) (clientv3.WatchChan, error)
	RequestLocker() KeyLocker
}

DAO defines CRUD method

func NewDAO

func NewDAO(client *clientv3.Client, timeout time.Duration) DAO

NewDAO creates a new instance of DAO interface

type Error

type Error struct {
	Key  string
	Code int
}

func (*Error) Error

func (e *Error) Error() string

type KeyLocker

type KeyLocker interface {
	// Lock is creating a lock for the given key
	Lock(key string) error
	// Unlock is removing the lock for the given key
	Unlock(key string)
}

KeyLocker is the interface that will provide methods to lock and unlock for a specific key Recommended usage : ```

err := k.Lock(key)
defer k.Unlock(key)
if err != nil {
  // do something with the error
}

```

type Query

type Query interface {
	Build() (string, error)
}

Query is the interface that all queryParameter should implement.

Jump to

Keyboard shortcuts

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