Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrWatchFailed indicates the watch failed. ErrWatchFailed = fmt.Errorf("etcd watch returns a nil chan") // ErrNoKey indicates the key does not exist. ErrNoKey = fmt.Errorf("etcd has no such key") // ErrTxnFailed indicates the txn failed. ErrTxnFailed = fmt.Errorf("role changed or target revision mismatch") )
View Source
var ( // ErrNotExist represents key not exist ErrNotExist = errors.New("not exist") )
Functions ¶
Types ¶
type Config ¶
type Config struct { Namespace string `toml:"namespace" json:"namespace"` Endpoints []string `toml:"endpoints" json:"endpoints"` DialTimeout int64 `toml:"dialTimeout" json:"dialTimeout"` }
Config represents state repository config
type Event ¶
type Event struct { Type EventType KeyValues []EventKeyValue Err error }
Event defines repository watch event on key or perfix
type EventKeyValue ¶
EventKeyValue represents task event
type Repository ¶
type Repository interface { // Get retrieves value for given key from repository Get(ctx context.Context, key string) ([]byte, error) // List retrieves list for given prefix from repository List(ctx context.Context, prefix string) ([][]byte, error) // Put puts a key-value pair into repository Put(ctx context.Context, key string, val []byte) error // Delete deletes value for given key from repository Delete(ctx context.Context, key string) error // Heartbeat does heartbeat on the key with a value and ttl Heartbeat(ctx context.Context, key string, value []byte, ttl int64) (<-chan Closed, error) // PutIfNotExist puts a key with a value, // 1) returns success if the key does not exist and puts success // 2) returns failure if key exist // When this operation success, it will do keepalive background for keep session PutIfNotExist(ctx context.Context, key string, value []byte, ttl int64) (bool, <-chan Closed, error) // Watch watches on a key. The watched events will be returned through the returned channel. Watch(ctx context.Context, key string) WatchEventChan // WatchPrefix watches on a prefix.All of the changes who has the prefix // will be notified through the WatchEventChan channel. WatchPrefix(ctx context.Context, prefixKey string) WatchEventChan // Batch puts k/v list, this operation is atomic Batch(ctx context.Context, batch Batch) (bool, error) // Close closes repository and release resources Close() error }
Repository stores state data, such as metadata/config/status/task etc.
func NewRepo ¶
func NewRepo(config Config) (Repository, error)
NewRepo create state repository based on config
Click to show internal directories.
Click to hide internal directories.