Documentation ¶
Index ¶
- Constants
- Variables
- func CancelContext(cancel context.CancelFunc)
- func CloseClient(client *Client)
- func CloseServer(s *Server)
- func DurationOrDefault(in *time.Duration, def time.Duration) time.Duration
- func RevokeLease(ctx context.Context, client *Client, lease *cli.LeaseGrantResponse)
- func StringIsInStringSlice(s string, strs []string) (resp bool)
- func URLSToStringSlice(urls []url.URL) []string
- func WaitForStructChOrErrCh(ctx context.Context, structCh <-chan struct{}, errCh <-chan error) error
- type Client
- type Config
- type Server
Constants ¶
const ( // EtcdClusterNamespace is the key namespace used for this package's etcd cluster EtcdClusterNamespace = "__etcd-cluster__/" // DefaultUnhealthyTTL is the grace period to wait before removing an unhealthy member DefaultUnhealthyTTL = time.Second * 15 // DefaultCleanUpInterval is the interval at which to poll for the health of the cluster DefaultCleanUpInterval = time.Second * 10 // DefaultStartUpGracePeriod is the graceperiod to wait for new cluster members to startup // before they're subject to health checks DefaultStartUpGracePeriod = time.Second * 60 // DefaultShutdownTimeout is the default time to wait for the server to shutdown cleanly DefaultShutdownTimeout = time.Second * 60 // DefaultDialTimeout is the default etcd dial timeout DefaultDialTimeout = time.Second * 5 // DefaultAutoSyncInterval is the default etcd autosync interval DefaultAutoSyncInterval = time.Second * 5 )
Variables ¶
var ( // ErrNameConflict is an error indicating that the server name is in conflict with an existing member of the cluster ErrNameConflict = fmt.Errorf("server name is in conflict with an existing cluster member") // ErrAlreadyRunning is an error indicating that the server is already running ErrAlreadyRunning = fmt.Errorf("server is already running") // ErrAlreadyStopped is an error indicating that the server is already stopped ErrAlreadyStopped = fmt.Errorf("server is already stopped") // ErrClusterNameConflict is an error indicating that the configured cluster name conflicts with the target cluster ErrClusterNameConflict = fmt.Errorf("cluster name either does not exist in the cluster under '/_etcd-cluster/name' or is different from this server's cluster name") )
Functions ¶
func CancelContext ¶
func CancelContext(cancel context.CancelFunc)
CancelContext is a helper function for canceling context using the context.CancelFunc if it isn't nil
func CloseClient ¶
func CloseClient(client *Client)
CloseClient closes an embetcd client with nil checks
func DurationOrDefault ¶
DurationOrDefault returns the pointed duration or the specified default
func RevokeLease ¶
func RevokeLease(ctx context.Context, client *Client, lease *cli.LeaseGrantResponse)
RevokeLease revokes a lease using a client as long as the client and lease are not nil
func StringIsInStringSlice ¶
StringIsInStringSlice returns true if the given string is in the slice of strings
func URLSToStringSlice ¶
URLSToStringSlice converts urls slices to string slices
Types ¶
type Client ¶
Client wraps around an etcd v3 client and adds some helper functions
func (*Client) PutWithKeepAlive ¶
func (c *Client) PutWithKeepAlive(ctx context.Context, key string, value string, ttl int64) (lease *cli.LeaseGrantResponse, keepAlive <-chan *cli.LeaseKeepAliveResponse, cancel context.CancelFunc, err error)
PutWithKeepAlive puts a key and value with a keep alive returns a lease, the keep alive response channel, and an err if one occurrs
type Config ¶
type Config struct { *embed.Config ClusterName string InitialCluster []string CleanUpInterval *time.Duration DialTimeout *time.Duration AutoSyncInterval *time.Duration StartupGracePeriod *time.Duration UnhealthyTTL *time.Duration RemoveMemberTimeout *time.Duration }
Config is a struct representing etcd config plus additional configurations we need for running etcd with this project
type Server ¶
type Server struct { // the currently running etcd server *embed.Etcd // contains filtered or unexported fields }
Server manages an etcd embedded server
func (*Server) IsRunning ¶
IsRunning indicates whether the server has been stopped or not and is thread safe