daemon

package
v1.1.0-beta.0...-9958228 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2024 License: Apache-2.0, Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Interface

type Interface interface {
	// OnStart start the service whatever the tidb-server is owner or not.
	OnStart(ctx context.Context)
	// OnBecomeOwner would be called once become the owner.
	// The context passed in would be canceled once it is no more the owner.
	OnBecomeOwner(ctx context.Context)
	// OnTick would be called periodically.
	// The error can be recorded.
	OnTick(ctx context.Context) error
	// Name returns the name which is used for tracing the daemon.
	Name() string
}

Interface describes the lifetime hook of a daemon application.

type OwnerDaemon

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

OwnerDaemon is a wrapper for running "daemon" in the TiDB cluster. Generally, it uses the etcd election API (wrapped in the `owner.Manager` interface), and shares nothing between nodes. Please make sure the daemon is "stateless" (i.e. it doesn't depend on the local storage or memory state.) This struct is "synchronous" (which means there are no race accessing of these variables.).

func New

func New(daemon Interface, manager owner.Manager, tickInterval time.Duration) *OwnerDaemon

New creates a new owner daemon.

func (*OwnerDaemon) Begin

func (od *OwnerDaemon) Begin(ctx context.Context) (func(), error)

Begin starts the daemon. It would do some bootstrap task, and return a closure that would begin the main loop.

func (*OwnerDaemon) Running

func (od *OwnerDaemon) Running() bool

Running tests whether the daemon is running (i.e. is it the owner?)

Jump to

Keyboard shortcuts

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