mysql

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

database initialization functionality

Index

Constants

View Source
const (
	MasterLockID        = 0
	HeartbeatMultiplier = 3
)
View Source
const (
	DefaultDBName             = "gomaster"
	DefaultHeartbeatFrequency = time.Second * 5
	DefaultTableName          = "masterlock"
	DefaultMaxOpenConnections = 4
	DefaultMaxWait            = time.Second * 5
)

Variables

This section is empty.

Functions

This section is empty.

Types

type MySQLBackend

type MySQLBackend struct {
	*MySQLBackendConfig
	// contains filtered or unexported fields
}

func NewMySQLBackend

func NewMySQLBackend(cfg *MySQLBackendConfig) *MySQLBackend

func (*MySQLBackend) Connect

func (m *MySQLBackend) Connect() error

func (*MySQLBackend) Lock

func (m *MySQLBackend) Lock(info *backend.MasterInfo) error

func (*MySQLBackend) Status

func (m *MySQLBackend) Status() (*backend.MasterInfo, error)

func (*MySQLBackend) UnLock

func (m *MySQLBackend) UnLock(masterID string) error

func (*MySQLBackend) WriteHeartbeat

func (m *MySQLBackend) WriteHeartbeat(info *backend.MasterInfo) error

type MySQLBackendConfig

type MySQLBackendConfig struct {
	// Supply a BaseDSN instead of credentials and host
	BaseDSN string

	// Supply User Password Host Port instead of a DSN
	User     string
	Password string
	Host     string
	Port     int //optional

	// Name of the DB to connect to.
	// If a name is supplied, a table will be created within that DB.
	// If a DB with the supplied name does not exist, and CreateDB is
	// set to true, it will be created.
	// If a DB name is not supplied, the default DB name will be used.
	// It will also attempt to create the DB if the CreateDB bool is
	// set to true.
	// DB creation is idempotent and can be left enabled if desired.
	DBName string

	// Optional: table name where the lock will exist (default: masterlock)
	TableName string

	// Optional: whether to attempt to create the DB
	CreateDB bool

	// optional params
	MaxWait            time.Duration
	MaxRetries         int
	MaxOpenConnections int

	// Optional: Frequency of master heartbeat write
	HeartBeatFreq time.Duration

	// Optional: Logger for the mongo backend to use (default: new logrus shim will be created)
	Logger log.Logger
	// contains filtered or unexported fields
}

type MySQLMasterInfo

type MySQLMasterInfo struct {
	ID            int       `db:"id,omitempty"`
	MasterID      string    `db:"master_id"`
	Version       string    `db:"version"`
	StartedAt     time.Time `db:"started_at"`
	LastHeartbeat time.Time `db:"last_heartbeat"`
}

Jump to

Keyboard shortcuts

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