zklock

package
v0.0.0-...-37fef2a Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2019 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Init = iota
	Assigned
	Releasing
	Deleting
)

Variables

View Source
var ZkClient *zk.Conn

Functions

func CreatePath

func CreatePath(path string) (string, error)

func IsLockInitialed

func IsLockInitialed() bool

func RegisterConfigHandler

func RegisterConfigHandler(namespace string, key string, action HandlerFunc) error

func ReleaseLock

func ReleaseLock(lockName string) error

func TryLock

func TryLock(lockName string) error

when get err, should send sns message

Types

type HandlerFunc

type HandlerFunc func(value []byte) error

type Status

type Status int

type Task

type Task struct {
	Payload   string //Native info for bussiness structs
	Path      string // friendly string for zk path composite, default is .substr(Payload, 0, 10)
	Weight    int    //bi
	Status    int
	Owner     string
	Timestamp int64
}

type ZkBalancer

type ZkBalancer struct {
	// contains filtered or unexported fields
}

func (*ZkBalancer) Init

func (zb *ZkBalancer) Init(name string, initTasks []Task) error

func (*ZkBalancer) OnAssign

func (zb *ZkBalancer) OnAssign(assignFunc func(tasks []Task) error)

worker callback WARN : as assignFunc may be called multi times, every time missing tasks should handle by client safely as accumulated releasing tasks,

those task may occur by history assignFunc calls, and should be finally released somehow

func (*ZkBalancer) Released

func (zb *ZkBalancer) Released(tasks []Task) error

worker call

func (*ZkBalancer) Start

func (zb *ZkBalancer) Start()

func (*ZkBalancer) Stop

func (zb *ZkBalancer) Stop()

type ZkLock

type ZkLock struct {
	// contains filtered or unexported fields
}

func Initialize

func Initialize(config ZkLockConfig) (*ZkLock, error)

type ZkLockConfig

type ZkLockConfig struct {
	ZkServers      string
	ConnectTimeOut int
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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