mysql

package
v0.0.0-...-1b273c6 Latest Latest
Warning

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

Go to latest
Published: May 30, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultDBName             = "master_election"
	DefaultTableName          = "master_lock"
	DefaultMaxOpenConnections = 4
	DefaultMaxWait            = time.Second * 5

	DefaultTimeout      = 10
	DefaultReadTimeout  = 10
	DefaultWriteTimeout = 10
)

Variables

View Source
var (
	ErrorUpdateHeartbeatFailed = errors.New("update heartbeat failed")
)

Functions

func NewMasterLock

func NewMasterLock(c *Config) lock.MasterLock

Types

type Config

type Config struct {
	BaseDSN string

	User     string
	Password string
	Host     string
	Port     int

	DBName    string
	TableName string

	CreateDB bool

	ConnMaxLifeTime    time.Duration
	MaxOpenConnections int

	Timeout      int
	ReadTimeout  int
	WriteTimeout int

	RowID uint
}

type MasterLock

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

func (*MasterLock) CurrentMaster

func (m *MasterLock) CurrentMaster() (*lock.Info, error)

func (*MasterLock) Init

func (m *MasterLock) Init(c *lock.MasterLockConfig) error

func (*MasterLock) Lock

func (m *MasterLock) Lock(info *lock.Info) (isSuccess bool, err error)

func (*MasterLock) UnLock

func (m *MasterLock) UnLock(info *lock.Info) (isSuccess bool, err error)

func (*MasterLock) WriteHeartbeat

func (m *MasterLock) WriteHeartbeat(info *lock.Info) error

Jump to

Keyboard shortcuts

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