github.com/pachyderm/pachyderm@v1.13.4/src/client/pkg/discovery/discovery.go (about)

     1  package discovery
     2  
     3  import (
     4  	"github.com/pachyderm/pachyderm/src/client/pkg/errors"
     5  )
     6  
     7  // ErrCancelled is returned when an action is cancelled by the user
     8  var ErrCancelled = errors.Errorf("pachyderm: cancelled by user")
     9  
    10  // Client defines Pachyderm's interface to key-value stores such as etcd.
    11  type Client interface {
    12  	// Close closes the underlying connection.
    13  	Close() error
    14  	// Get gets the value of a key
    15  	// Keys can be directories of the form a/b/c, see etcd for details.
    16  	// the error will be non-nil if the key does not exist.
    17  	Get(key string) (string, error)
    18  	// GetAll returns all of the keys in a directory and its subdirectories as
    19  	// a map from absolute keys to values.
    20  	// the map will be empty if no keys are found.
    21  	GetAll(key string) (map[string]string, error)
    22  	// WatchAll calls callBack with changes to a directory
    23  	WatchAll(key string, cancel chan bool, callBack func(map[string]string) error) error
    24  	// Set sets the value for a key.
    25  	// ttl is in seconds.
    26  	Set(key string, value string, ttl uint64) error
    27  	// Delete deletes a key.
    28  	Delete(key string) error
    29  	// Create is like Set but only succeeds if the key doesn't already exist.
    30  	// ttl is in seconds.
    31  	Create(key string, value string, ttl uint64) error
    32  	// CheckAndSet is like Set but only succeeds if the key is already set to oldValue.
    33  	// ttl is in seconds.
    34  	CheckAndSet(key string, value string, ttl uint64, oldValue string) error
    35  }
    36  
    37  // NewEtcdClient creates an etcdClient with the given addresses.
    38  func NewEtcdClient(addresses ...string) Client {
    39  	return newEtcdClient(addresses...)
    40  }