owner

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2017 License: Apache-2.0 Imports: 14 Imported by: 386

Documentation

Index

Constants

View Source
const (
	// NewSessionDefaultRetryCnt is the default retry times when create new session.
	NewSessionDefaultRetryCnt = 3
	// NewSessionRetryUnlimited is the unlimited retry times when create new session.
	NewSessionRetryUnlimited = math.MaxInt64
)

Variables

View Source
var ManagerSessionTTL = 60

ManagerSessionTTL is the etcd session's TTL in seconds. It's exported for testing.

Functions

func GetOwnerInfo

func GetOwnerInfo(ctx goctx.Context, elec *concurrency.Election, logPrefix, id string) (string, error)

GetOwnerInfo gets the owner information.

func NewSession

func NewSession(ctx goctx.Context, logPrefix string, etcdCli *clientv3.Client, retryCnt, ttl int) (*concurrency.Session, error)

NewSession creates a new etcd session.

Types

type Manager

type Manager interface {
	// ID returns the ID of the manager.
	ID() string
	// IsOwner returns whether the ownerManager is the owner.
	IsOwner() bool
	// SetOwner sets whether the ownerManager is the owner.
	SetOwner(isOwner bool)
	// GetOwnerID gets the owner ID.
	GetOwnerID(ctx goctx.Context) (string, error)
	// CampaignOwner campaigns the owner.
	CampaignOwner(ctx goctx.Context) error
	// Cancel cancels this etcd ownerManager campaign.
	Cancel()
}

Manager is used to campaign the owner and manage the owner information.

func NewMockManager

func NewMockManager(id string, cancel goctx.CancelFunc) Manager

NewMockManager creates a new mock Manager.

func NewOwnerManager

func NewOwnerManager(etcdCli *clientv3.Client, prompt, id, key string, cancel goctx.CancelFunc) Manager

NewOwnerManager creates a new Manager.

Jump to

Keyboard shortcuts

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