config

package
v0.0.0-...-56e5da9 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2018 License: MPL-2.0 Imports: 21 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	DefaultBindPort  int = 8191
	DefaultClusterID     = "udup-cluster"
)

This is the default port that we use for Serf communication

View Source
const (
	DefaultRegion   = "global"
	DefaultDC       = "dc1"
	DefaultSerfPort = 8192
)

Variables

View Source
var (
	DefaultRPCAddr = &net.TCPAddr{IP: net.ParseIP("127.0.0.1"), Port: 8191}
)

Functions

This section is empty.

Types

type ClientConfig

type ClientConfig struct {
	// StateDir is where we store our state
	StateDir string

	// AllocDir is where we store data for allocations
	AllocDir string

	// LogOutput is the destination for logs
	LogOutput io.Writer

	// Specify the log file name. The empty string means to log to stdout.
	LogFile string

	// Region is the clients region
	Region string

	// Servers is a list of known server addresses. These are as "host:port"
	Servers []string

	// RPCHandler can be provided to avoid network traffic if the
	// server is running locally.
	RPCHandler RPCHandler

	// Node provides the base node
	Node *models.Node

	// Version is the version of the Udup client
	Version string

	// Revision is the commit number of the Udup client
	Revision string

	// ConsulConfig is this Agent's Consul configuration
	ConsulConfig *ConsulConfig

	NatsAddr string

	MaxPayload int

	// StatsCollectionInterval is the interval at which the Udup client
	// collects resource usage stats
	StatsCollectionInterval time.Duration

	// PublishNodeMetrics determines whether server is going to publish node
	// level metrics to remote Metric sinks
	PublishNodeMetrics bool

	// PublishAllocationMetrics determines whether server is going to publish
	// allocation metrics to remote Metric sinks
	PublishAllocationMetrics bool

	// LogLevel is the level of the logs to putout
	LogLevel string

	// NoHostUUID disables using the host's UUID and will force generation of a
	// random UUID.
	NoHostUUID bool
}

Config is used to parameterize and configure the behavior of the client

func DefaultClientConfig

func DefaultClientConfig() *ClientConfig

DefaultConfig returns the default configuration

func (*ClientConfig) Copy

func (c *ClientConfig) Copy() *ClientConfig

type ConsulConfig

type ConsulConfig struct {
	// ServerServiceName is the name of the service that Udup uses to register
	// servers with Consul
	ServerServiceName string `mapstructure:"server_service_name"`

	// ClientServiceName is the name of the service that Udup uses to register
	// clients with Consul
	ClientServiceName string `mapstructure:"client_service_name"`

	// AutoAdvertise determines if this Udup Agent will advertise its
	// services via Consul.  When true, Udup Agent will register
	// services with Consul.
	AutoAdvertise *bool `mapstructure:"auto_advertise"`

	// ChecksUseAdvertise specifies that Consul checks should use advertise
	// address instead of bind address
	ChecksUseAdvertise *bool `mapstructure:"checks_use_advertise"`

	// Addr is the address of the local Consul agent
	Addr string `mapstructure:"address"`

	// Timeout is used by Consul HTTP Client
	Timeout time.Duration `mapstructure:"timeout"`

	// Token is used to provide a per-request ACL token. This options overrides
	// the agent's default token
	Token string `mapstructure:"token"`

	// Auth is the information to use for http access to Consul agent
	Auth string `mapstructure:"auth"`

	// EnableSSL sets the transport scheme to talk to the Consul agent as https
	EnableSSL *bool `mapstructure:"ssl"`

	// VerifySSL enables or disables SSL verification when the transport scheme
	// for the consul api client is https
	VerifySSL *bool `mapstructure:"verify_ssl"`

	// CAFile is the path to the ca certificate used for Consul communication
	CAFile string `mapstructure:"ca_file"`

	// CertFile is the path to the certificate for Consul communication
	CertFile string `mapstructure:"cert_file"`

	// KeyFile is the path to the private key for Consul communication
	KeyFile string `mapstructure:"key_file"`

	// ServerAutoJoin enables Udup servers to find peers by querying Consul and
	// joining them
	ServerAutoJoin *bool `mapstructure:"server_auto_join"`

	// ClientAutoJoin enables Udup servers to find addresses of Udup servers
	// and register with them
	ClientAutoJoin *bool `mapstructure:"client_auto_join"`
}

ConsulConfig contains the configuration information necessary to communicate with a Consul Agent in order to:

- Register services and their checks with Consul

  • Bootstrap this Udup Client with the list of Udup Servers registered with Consul

Both the Agent and the executor need to be able to import ConsulConfig.

func DefaultConsulConfig

func DefaultConsulConfig() *ConsulConfig

DefaultConsulConfig() returns the canonical defaults for the Udup `consul` configuration.

func (*ConsulConfig) ApiConfig

func (c *ConsulConfig) ApiConfig() (*consul.Config, error)

ApiConfig() returns a usable Consul config that can be passed directly to hashicorp/consul/api. NOTE: datacenter is not set

func (*ConsulConfig) Copy

func (c *ConsulConfig) Copy() *ConsulConfig

Copy returns a copy of this Consul config.

func (*ConsulConfig) Merge

func (a *ConsulConfig) Merge(b *ConsulConfig) *ConsulConfig

Merge merges two Consul Configurations together.

type DataSource

type DataSource struct {
	TableSchema string
	Tables      []*Table
}

TableName is the table configuration slave restrict replication to a given table

func (*DataSource) String

func (d *DataSource) String() string

type DriverCtx

type DriverCtx struct {
	DriverConfig *MySQLDriverConfig
}

type MySQLDriverConfig

type MySQLDriverConfig struct {
	DataDir     string
	MaxFileSize int64
	//Ref:http://dev.mysql.com/doc/refman/5.7/en/replication-options-slave.html#option_mysqld_replicate-do-table
	ReplicateDoDb         []*DataSource
	ReplicateIgnoreDb     []*DataSource
	DropTableIfExists     bool
	ExpandSyntaxSupport   bool
	ReplChanBufferSize    int64
	MsgBytesLimit         int
	TrafficAgainstLimits  int
	TotalTransferredBytes int
	SkipRenamedColumns    bool
	MaxRetries            int64
	ChunkSize             int64

	MaxLagMillisecondsThrottleThreshold int64

	RowsEstimate  int64
	DeltaEstimate int64
	TimeZone      string
	GroupCount    int
	GroupMaxSize  int
	GroupTimeout  int // millisecond

	Gtid                  string
	GtidStart             string
	AutoGtid              bool // For internal use. Might be changed without notification.
	NatsAddr              string
	ParallelWorkers       int
	ConnectionConfig      *umconf.ConnectionConfig
	SystemVariables       map[string]string
	HasSuperPrivilege     bool
	BinlogFormat          string
	BinlogRowImage        string
	SqlMode               string
	MySQLVersion          string
	MySQLServerUuid       string
	StartTime             time.Time
	RowCopyStartTime      time.Time
	RowCopyEndTime        time.Time
	LockTablesStartTime   time.Time
	RenameTablesStartTime time.Time
	RenameTablesEndTime   time.Time
	PointOfInterestTime   time.Time

	TotalDeltaCopied int64
	TotalRowsCopied  int64
	TotalRowsReplay  int64

	Stage                string
	ApproveHeterogeneous bool
	SkipCreateDbTable    bool

	CountingRowsFlag            int64
	UserCommandedUnpostponeFlag int64

	SkipPrivilegeCheck bool
	// contains filtered or unexported fields
}

func (*MySQLDriverConfig) ElapsedRowCopyTime

func (m *MySQLDriverConfig) ElapsedRowCopyTime() time.Duration

ElapsedRowCopyTime returns time since starting to copy chunks of rows

func (*MySQLDriverConfig) ElapsedTime

func (m *MySQLDriverConfig) ElapsedTime() time.Duration

ElapsedTime returns time since very beginning of the process

func (*MySQLDriverConfig) GetCriticalLoad

func (m *MySQLDriverConfig) GetCriticalLoad() umconf.LoadMap

func (*MySQLDriverConfig) GetMaxLoad

func (m *MySQLDriverConfig) GetMaxLoad() umconf.LoadMap

func (*MySQLDriverConfig) GetNiceRatio

func (m *MySQLDriverConfig) GetNiceRatio() float64

func (*MySQLDriverConfig) GetTotalDeltaCopied

func (m *MySQLDriverConfig) GetTotalDeltaCopied() int64

func (*MySQLDriverConfig) GetTotalRowsCopied

func (m *MySQLDriverConfig) GetTotalRowsCopied() int64

GetTotalRowsCopied returns the accurate number of rows being copied (affected) This is not exactly the same as the rows being iterated via chunks, but potentially close enough

func (*MySQLDriverConfig) GetTotalRowsReplay

func (m *MySQLDriverConfig) GetTotalRowsReplay() int64

func (*MySQLDriverConfig) MarkRowCopyEndTime

func (m *MySQLDriverConfig) MarkRowCopyEndTime()

ElapsedRowCopyTime returns time since starting to copy chunks of rows

func (*MySQLDriverConfig) MarkRowCopyStartTime

func (m *MySQLDriverConfig) MarkRowCopyStartTime()

MarkRowCopyStartTime

func (*MySQLDriverConfig) RequiresBinlogFormatChange

func (m *MySQLDriverConfig) RequiresBinlogFormatChange() bool

RequiresBinlogFormatChange is `true` when the original binlog format isn't `ROW`

func (*MySQLDriverConfig) SetDefault

func (a *MySQLDriverConfig) SetDefault() *MySQLDriverConfig

func (*MySQLDriverConfig) TimeSincePointOfInterest

func (m *MySQLDriverConfig) TimeSincePointOfInterest() time.Duration

type RPCHandler

type RPCHandler interface {
	RPC(method string, args interface{}, reply interface{}) error
}

RPCHandler can be provided to the Client if there is a local server to avoid going over the network. If not provided, the Client will maintain a connection pool to the servers

type ServerConfig

type ServerConfig struct {
	// Bootstrap mode is used to bring up the first Udup server.  It is
	// required so that it can elect a leader without any other nodes
	// being present
	Bootstrap bool

	// BootstrapExpect mode is used to automatically bring up a
	// collection of Udup servers. This can be used to automatically
	// bring up a collection of nodes.  All operations on BootstrapExpect
	// must be handled via `atomic.*Int32()` calls.
	BootstrapExpect int32

	// DataDir is the directory to store our state in
	DataDir string

	// LogOutput is the location to write logs to. If this is not set,
	// logs will go to stderr.
	LogOutput io.Writer

	// RPCAddr is the RPC address used by Udup. This should be reachable
	// by the other servers and clients
	RPCAddr *net.TCPAddr

	// RPCAdvertise is the address that is advertised to other nodes for
	// the RPC endpoint. This can differ from the RPC address, if for example
	// the RPCAddr is unspecified "0.0.0.0:8190", but this address must be
	// reachable
	RPCAdvertise *net.TCPAddr

	// RaftConfig is the configuration used for Raft in the local DC
	RaftConfig *raft.Config

	// RaftTimeout is applied to any network traffic for raft. Defaults to 10s.
	RaftTimeout time.Duration

	// SerfConfig is the configuration for the serf cluster
	SerfConfig *serf.Config

	// Node name is the name we use to advertise. Defaults to hostname.
	NodeName string

	// Region is the region this Udup server belongs to.
	Region string

	// Datacenter is the datacenter this Udup server belongs to.
	Datacenter string

	// Build is a string that is gossiped around, and can be used to help
	// operators track which versions are actively deployed
	Build string

	// NumSchedulers is the number of scheduler thread that are run.
	// This can be as many as one per core, or zero to disable this server
	// from doing any scheduling work.
	NumSchedulers int

	// EnabledSchedulers controls the set of sub-schedulers that are
	// enabled for this server to handle. This will restrict the evaluations
	// that the workers dequeue for processing.
	EnabledSchedulers []string

	// ReconcileInterval controls how often we reconcile the strongly
	// consistent store with the Serf info. This is used to handle nodes
	// that are force removed, as well as intermittent unavailability during
	// leader election.
	ReconcileInterval time.Duration

	// EvalNackTimeout controls how long we allow a sub-scheduler to
	// work on an evaluation before we consider it failed and Nack it.
	// This allows that evaluation to be handed to another sub-scheduler
	// to work on. Defaults to 60 seconds. This should be long enough that
	// no evaluation hits it unless the sub-scheduler has failed.
	EvalNackTimeout time.Duration

	// EvalDeliveryLimit is the limit of attempts we make to deliver and
	// process an evaluation. This is used so that an eval that will never
	// complete eventually fails out of the system.
	EvalDeliveryLimit int

	// MinHeartbeatTTL is the minimum time between heartbeats.
	// This is used as a floor to prevent excessive updates.
	MinHeartbeatTTL time.Duration

	// MaxHeartbeatsPerSecond is the maximum target rate of heartbeats
	// being processed per second. This allows the TTL to be increased
	// to meet the target rate.
	MaxHeartbeatsPerSecond float64

	// HeartbeatGrace is the additional time given as a grace period
	// beyond the TTL to account for network and processing delays
	// as well as clock skew.
	HeartbeatGrace time.Duration

	// FailoverHeartbeatTTL is the TTL applied to heartbeats after
	// a new leader is elected, since we no longer know the status
	// of all the heartbeats.
	FailoverHeartbeatTTL time.Duration

	// ConsulConfig is this Agent's Consul configuration
	ConsulConfig *ConsulConfig

	// RPCHoldTimeout is how long an RPC can be "held" before it is errored.
	// This is used to paper over a loss of leadership by instead holding RPCs,
	// so that the caller experiences a slow response rather than an error.
	// This period is meant to be long enough for a leader election to take
	// place, and a small jitter is applied to avoid a thundering herd.
	RPCHoldTimeout time.Duration
}

Config is used to parameterize the server

func DefaultServerConfig

func DefaultServerConfig() *ServerConfig

DefaultConfig returns the default configuration

type Table

type Table struct {
	TableName   string
	TableSchema string
	Counter     int64

	OriginalTableColumns *umconf.ColumnList
	UseUniqueKey         *umconf.UniqueKey
	Iteration            int64

	TableType    string
	TableEngine  string
	RowsEstimate int64

	Where string // TODO load from job description
}

func NewTable

func NewTable(schemaName string, tableName string) *Table

type TableContext

type TableContext struct {
	Table          *Table
	WhereCtx       *WhereContext
	DefChangedSent bool
}

func NewTableContext

func NewTableContext(table *Table, whereCtx *WhereContext) *TableContext

func (*TableContext) WhereTrue

func (t *TableContext) WhereTrue(values *umconf.ColumnValues) (bool, error)

type WhereContext

type WhereContext struct {
	Where     string
	Ast       qlexpr.Node
	FieldsMap map[string]int
	IsDefault bool // is 'true'
}

func NewWhereCtx

func NewWhereCtx(where string, table *Table) (*WhereContext, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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