etcd

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const APP = "etcd"

Variables

Functions

func Del

func Del(key string, opts ...clientv3.OpOption) error

func ExecAllTask

func ExecAllTask(key string, ttl int, task func()) error

ExecAllTask 基于分布式的全部执行任务

func ExecOnceTask

func ExecOnceTask(key string, ttl int, task func()) error

ExecOnceTask 基于分布式的唯一执行任务

func Get

func Get(key string, opts ...clientv3.OpOption) ([]*mvccpb.KeyValue, error)

func New

func New(e *Etcd) (*clientv3.Client, error)

func Put

func Put(key, value string, opts ...clientv3.OpOption) error

func PutWithLease

func PutWithLease(key, val string, ttl int64, opts ...clientv3.OpOption) error

func Register

func Register(serverName, addr string, ttl int64) error

func Unregister

func Unregister(serverName, addr string) error

Types

type Etcd

type Etcd struct {
	Nodes    []string `mapstructure:"nodes" default:"" yaml:"nodes" json:"nodes"`
	Username string   `mapstructure:"username" default:"" yaml:"username" json:"username"`
	Password string   `mapstructure:"password" default:"" yaml:"password" json:"password"`
	Timeout  int      `mapstructure:"timeout" default:"10" yaml:"timeout" json:"timeout"`
	TTL      int64    `mapstructure:"ttl" default:"10" yaml:"ttl" json:"ttl"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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