owner

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

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, logCtx context.Context, elec *concurrency.Election, id string) (string, error)

GetOwnerInfo gets the owner information.

Types

type DDLOwnerChecker

type DDLOwnerChecker interface {
	// IsOwner returns whether the ownerManager is the owner.
	IsOwner() bool
}

DDLOwnerChecker is used to check whether tidb is owner.

type Manager

type Manager interface {
	// ID returns the ID of the manager.
	ID() string
	// IsOwner returns whether the ownerManager is the owner.
	IsOwner() bool
	// RetireOwner make the manager to be a not owner. It's exported for testing.
	RetireOwner()
	// GetOwnerID gets the owner ID.
	GetOwnerID(ctx context.Context) (string, error)
	// CampaignOwner campaigns the owner.
	CampaignOwner() error
	// ResignOwner lets the owner start a new election.
	ResignOwner(ctx context.Context) error
	// Cancel cancels this etcd ownerManager.
	Cancel()
	// RequireOwner requires the ownerManager is owner.
	RequireOwner(ctx context.Context) error
	// CampaignCancel cancels one etcd campaign
	CampaignCancel()

	// SetBeOwnerHook sets a hook. The hook is called before becoming an owner.
	SetBeOwnerHook(hook func())
}

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

func NewMockManager

func NewMockManager(ctx context.Context, id string) Manager

NewMockManager creates a new mock Manager.

func NewOwnerManager

func NewOwnerManager(ctx context.Context, etcdCli *clientv3.Client, prompt, id, key string) Manager

NewOwnerManager creates a new Manager.

Jump to

Keyboard shortcuts

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