etcdclient

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (

	//key /crony/node/<node_uuid>
	KeyEtcdNodeProfile = keyEtcdProfile + "node/"
	KeyEtcdNode        = KeyEtcdNodeProfile + "%s"

	//key  /crony/proc/<node_uuid>/<job_id>/<pid>
	KeyEtcdProcProfile     = keyEtcdProfile + "proc/"
	KeyEtcdNodeProcProfile = KeyEtcdProcProfile + "%s/"
	KeyEtcdJobProcProfile  = KeyEtcdNodeProcProfile + "%d/"
	KeyEtcdProc            = KeyEtcdJobProcProfile + "%d"

	//key /crony/job/<node_uuid>/<job_id>
	KeyEtcdJobProfile = keyEtcdProfile + "job/%s/"
	KeyEtcdJob        = KeyEtcdJobProfile + "%d"

	// key /crony/once/<jobID>
	KeyEtcdOnceProfile = keyEtcdProfile + "once/"
	KeyEtcdOnce        = KeyEtcdOnceProfile + "%d"

	KeyEtcdLockProfile = keyEtcdProfile + "lock/"
	KeyEtcdLock        = KeyEtcdLockProfile + "%s"

	// key /crony/system/<node_uuid>
	KeyEtcdSystemProfile = keyEtcdProfile + "system/"
	KeyEtcdSystemSwitch  = KeyEtcdSystemProfile + "switch/" + "%s"
	KeyEtcdSystemGet     = KeyEtcdSystemProfile + "get/" + "%s"
)

Variables

This section is empty.

Functions

func DelLock

func DelLock(key string) error

func Delete

func Delete(key string, opts ...clientv3.OpOption) (*clientv3.DeleteResponse, error)

func Get

func Get(key string, opts ...clientv3.OpOption) (*clientv3.GetResponse, error)

func GetLock

func GetLock(key string, id clientv3.LeaseID) (bool, error)

func Grant

func Grant(ttl int64) (*clientv3.LeaseGrantResponse, error)

func IsValidAsKeyPath

func IsValidAsKeyPath(s string) bool

func NewEtcdTimeoutContext

func NewEtcdTimeoutContext() (context.Context, context.CancelFunc)

NewEtcdTimeoutContext return a new etcdTimeoutContext

func Put

func Put(key, val string, opts ...clientv3.OpOption) (*clientv3.PutResponse, error)

func PutWithModRev

func PutWithModRev(key, val string, rev int64) (*clientv3.PutResponse, error)

func PutWithTtl

func PutWithTtl(key, val string, ttl int64) (*clientv3.PutResponse, error)

func Watch

func Watch(key string, opts ...clientv3.OpOption) clientv3.WatchChan

Types

type Client

type Client struct {
	*clientv3.Client
	// contains filtered or unexported fields
}

func GetEtcdClient

func GetEtcdClient() *Client

func Init

func Init(endpoints []string, dialTimeout, reqTimeout int64) (*Client, error)

type ServerReg

type ServerReg struct {
	Client *Client

	//time-to-live
	Ttl int64
	// contains filtered or unexported fields
}

func NewServerReg

func NewServerReg(ttl int64) *ServerReg

func (*ServerReg) Register

func (s *ServerReg) Register(key string, value string) error

func (*ServerReg) RevokeLease

func (s *ServerReg) RevokeLease() error

func (*ServerReg) Stop

func (s *ServerReg) Stop()

type Watcher

type Watcher interface {
	Watch() error

	Close() error
}

Jump to

Keyboard shortcuts

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