utils

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2025 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Exit

func Exit(code int)

Exit exits the program with the given code.

func GetExpectedPrimaryFlag

func GetExpectedPrimaryFlag(client *clientv3.Client, primaryPath string) string

GetExpectedPrimaryFlag gets the expected primary flag.

func InitClient

func InitClient(s server) error

InitClient initializes the etcd and http clients.

func KeepExpectedPrimaryAlive

func KeepExpectedPrimaryAlive(ctx context.Context, cli *clientv3.Client, exitPrimary chan<- struct{},
	leaseTimeout int64, leaderPath, memberValue, service string) (*election.Lease, error)

KeepExpectedPrimaryAlive keeps the expected primary alive. We use lease to keep `expected primary` healthy. ONLY reset by the following conditions: - changed by `{service}/primary/transfer` API. - leader lease expired. ONLY primary called this function.

func PromHandler

func PromHandler() gin.HandlerFunc

PromHandler is a handler to get prometheus metrics.

func Register

func Register(s server, serviceName string) (*discovery.ServiceRegistryEntry, *discovery.ServiceRegister, error)

Register registers the service.

func StartGRPCAndHTTPServers

func StartGRPCAndHTTPServers(s server, serverReadyChan chan<- struct{}, l net.Listener)

StartGRPCAndHTTPServers starts the grpc and http servers.

func StatusHandler

func StatusHandler(c *gin.Context)

StatusHandler is a handler to get status info.

func StopGRPCServer

func StopGRPCServer(s server)

StopGRPCServer stops the grpc server.

func StopHTTPServer

func StopHTTPServer(s server)

StopHTTPServer stops the http server.

func TransferPrimary

func TransferPrimary(client *clientv3.Client, lease *election.Lease, serviceName,
	oldPrimary, newPrimary string, keyspaceGroupID uint32, tsoMembersMap map[string]bool) error

TransferPrimary transfers the primary of the specified service. keyspaceGroupID is optional, only used for TSO service.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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