utils

package
v0.0.0-...-93ee6ed Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2020 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Rendezvous (highest random weight) hashing

Package utils is a generated GoMock package.

Index

Constants

View Source
const (
	EventZkWatchInit   int32 = 0
	EventZkNodeCreated int32 = 1
	EventZkNodeDeleted int32 = 2
)

Variables

View Source
var SeqIdRegexp = regexp.MustCompile(`\-n(\d+)`)

Functions

func InterruptSignal

func InterruptSignal() <-chan os.Signal

func NodeIpAddress

func NodeIpAddress() (string, error)

func NodeUuid

func NodeUuid() (string, error)

func ParseSeqId

func ParseSeqId(znode string) (int64, error)

func RendezvousHashScore

func RendezvousHashScore(node, key string, weight float64) float64

func VolatileNodeUuid

func VolatileNodeUuid() (string, error)

func WaitUntilAllSuccessful

func WaitUntilAllSuccessful(ctx context.Context, n int, errors chan error) error

Types

type Broadcast

type Broadcast interface {
	Close()
	Send(interface{})
	Listen(int) <-chan interface{}
}

func NewBroadcast

func NewBroadcast() Broadcast

func NewThreadSafeBroadcast

func NewThreadSafeBroadcast() Broadcast

type ChildrenChangedEvent

type ChildrenChangedEvent struct {
	Type  int32
	ZNode string
}

type MockZookeeper

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

MockZookeeper is a mock of Zookeeper interface

func NewMockZookeeper

func NewMockZookeeper(ctrl *gomock.Controller) *MockZookeeper

NewMockZookeeper creates a new mock instance

func (*MockZookeeper) Children

func (m *MockZookeeper) Children(arg0 string) ([]string, error)

Children mocks base method

func (*MockZookeeper) ChildrenChanges

func (m *MockZookeeper) ChildrenChanges(arg0 context.Context, arg1 string) (<-chan ChildrenChangedEvent, <-chan error)

ChildrenChanges mocks base method

func (*MockZookeeper) ChildrenW

func (m *MockZookeeper) ChildrenW(arg0 string) ([]string, <-chan zk.Event, error)

ChildrenW mocks base method

func (*MockZookeeper) Close

func (m *MockZookeeper) Close()

Close mocks base method

func (*MockZookeeper) Create

func (m *MockZookeeper) Create(arg0 string, arg1 []byte, arg2 int32) (string, error)

Create mocks base method

func (*MockZookeeper) CreatePath

func (m *MockZookeeper) CreatePath(arg0 string, arg1 []byte, arg2 int32) (string, error)

CreatePath mocks base method

func (*MockZookeeper) CreateProtectedEphemeralSequential

func (m *MockZookeeper) CreateProtectedEphemeralSequential(arg0 string, arg1 []byte) (string, error)

CreateProtectedEphemeralSequential mocks base method

func (*MockZookeeper) Delete

func (m *MockZookeeper) Delete(arg0 string) error

Delete mocks base method

func (*MockZookeeper) DeleteRecursive

func (m *MockZookeeper) DeleteRecursive(arg0 string) error

DeleteRecursive mocks base method

func (*MockZookeeper) EXPECT

EXPECT returns an object that allows the caller to indicate expected use

func (*MockZookeeper) Exists

func (m *MockZookeeper) Exists(arg0 string) (bool, error)

Exists mocks base method

func (*MockZookeeper) ExistsW

func (m *MockZookeeper) ExistsW(arg0 string) (bool, <-chan zk.Event, error)

ExistsW mocks base method

func (*MockZookeeper) Get

func (m *MockZookeeper) Get(arg0 string) ([]byte, error)

Get mocks base method

func (*MockZookeeper) GetW

func (m *MockZookeeper) GetW(arg0 string) ([]byte, <-chan zk.Event, error)

GetW mocks base method

func (*MockZookeeper) Multi

func (m *MockZookeeper) Multi(arg0 ...interface{}) error

Multi mocks base method

type MockZookeeperMockRecorder

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

MockZookeeperMockRecorder is the mock recorder for MockZookeeper

func (*MockZookeeperMockRecorder) Children

func (mr *MockZookeeperMockRecorder) Children(arg0 interface{}) *gomock.Call

Children indicates an expected call of Children

func (*MockZookeeperMockRecorder) ChildrenChanges

func (mr *MockZookeeperMockRecorder) ChildrenChanges(arg0, arg1 interface{}) *gomock.Call

ChildrenChanges indicates an expected call of ChildrenChanges

func (*MockZookeeperMockRecorder) ChildrenW

func (mr *MockZookeeperMockRecorder) ChildrenW(arg0 interface{}) *gomock.Call

ChildrenW indicates an expected call of ChildrenW

func (*MockZookeeperMockRecorder) Close

func (mr *MockZookeeperMockRecorder) Close() *gomock.Call

Close indicates an expected call of Close

func (*MockZookeeperMockRecorder) Create

func (mr *MockZookeeperMockRecorder) Create(arg0, arg1, arg2 interface{}) *gomock.Call

Create indicates an expected call of Create

func (*MockZookeeperMockRecorder) CreatePath

func (mr *MockZookeeperMockRecorder) CreatePath(arg0, arg1, arg2 interface{}) *gomock.Call

CreatePath indicates an expected call of CreatePath

func (*MockZookeeperMockRecorder) CreateProtectedEphemeralSequential

func (mr *MockZookeeperMockRecorder) CreateProtectedEphemeralSequential(arg0, arg1 interface{}) *gomock.Call

CreateProtectedEphemeralSequential indicates an expected call of CreateProtectedEphemeralSequential

func (*MockZookeeperMockRecorder) Delete

func (mr *MockZookeeperMockRecorder) Delete(arg0 interface{}) *gomock.Call

Delete indicates an expected call of Delete

func (*MockZookeeperMockRecorder) DeleteRecursive

func (mr *MockZookeeperMockRecorder) DeleteRecursive(arg0 interface{}) *gomock.Call

DeleteRecursive indicates an expected call of DeleteRecursive

func (*MockZookeeperMockRecorder) Exists

func (mr *MockZookeeperMockRecorder) Exists(arg0 interface{}) *gomock.Call

Exists indicates an expected call of Exists

func (*MockZookeeperMockRecorder) ExistsW

func (mr *MockZookeeperMockRecorder) ExistsW(arg0 interface{}) *gomock.Call

ExistsW indicates an expected call of ExistsW

func (*MockZookeeperMockRecorder) Get

func (mr *MockZookeeperMockRecorder) Get(arg0 interface{}) *gomock.Call

Get indicates an expected call of Get

func (*MockZookeeperMockRecorder) GetW

func (mr *MockZookeeperMockRecorder) GetW(arg0 interface{}) *gomock.Call

GetW indicates an expected call of GetW

func (*MockZookeeperMockRecorder) Multi

func (mr *MockZookeeperMockRecorder) Multi(arg0 ...interface{}) *gomock.Call

Multi indicates an expected call of Multi

type PriorityQueue

type PriorityQueue interface {
	Len() int
	Push(*PriorityQueueItem)
	Pop() *PriorityQueueItem
	Peek() *PriorityQueueItem
	Reverse() PriorityQueue
	ToSlice() []*PriorityQueueItem
	ToIterator() <-chan *PriorityQueueItem
	Values() []interface{}
}

func NewMaxPriorityQueue

func NewMaxPriorityQueue(items ...*PriorityQueueItem) PriorityQueue

func NewMinPriorityQueue

func NewMinPriorityQueue(items ...*PriorityQueueItem) PriorityQueue

type PriorityQueueItem

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

func NewPriorityQueueItem

func NewPriorityQueueItem(priority float32, value interface{}) *PriorityQueueItem

func (*PriorityQueueItem) Priority

func (item *PriorityQueueItem) Priority() float32

Item

func (*PriorityQueueItem) Value

func (item *PriorityQueueItem) Value() interface{}

type Set

type Set interface {
	Len() int
	Clear()
	Add(interface{})
	Remove(interface{})
	Contains(interface{}) bool
	Equal(Set) bool
	Intersection(Set) Set
	Difference(Set) Set
	Union(Set) Set
	ToIterator() <-chan interface{}
	ToSlice() []interface{}
	String() string
	Rand() interface{}
}

func NewSet

func NewSet(elements ...interface{}) Set

func NewThreadSafeSet

func NewThreadSafeSet(elements ...interface{}) Set

type Stack

type Stack interface {
	Len() int
	Push(interface{})
	Pop() interface{}
}

func NewStack

func NewStack() Stack

func NewThreadSafeStack

func NewThreadSafeStack() Stack

type Zookeeper

type Zookeeper interface {
	Close()
	Children(string) ([]string, error)
	ChildrenW(string) ([]string, <-chan zk.Event, error)
	ChildrenChanges(context.Context, string) (<-chan ChildrenChangedEvent, <-chan error)
	Create(string, []byte, int32) (string, error)
	CreateProtectedEphemeralSequential(string, []byte) (string, error)
	CreatePath(string, []byte, int32) (string, error)
	Delete(string) error
	DeleteRecursive(string) error
	Exists(string) (bool, error)
	ExistsW(string) (bool, <-chan zk.Event, error)
	Get(string) ([]byte, error)
	GetW(string) ([]byte, <-chan zk.Event, error)
	Multi(...interface{}) error
}

func NewZookeeper

func NewZookeeper(config ZookeeperConfig) (Zookeeper, error)

func NewZookeeperFromConn

func NewZookeeperFromConn(conn *zk.Conn, config ZookeeperConfig) (Zookeeper, error)

type ZookeeperConfig

type ZookeeperConfig struct {
	Nodes    []string
	Timeout  time.Duration
	BasePath string
}

Jump to

Keyboard shortcuts

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