entity

package
v0.0.0-...-e215c4f Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2019 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Copyright 2018 The ChuBao Authors.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const (
	LocalSingleAddr = "127.0.0.1"
	LocalCastAddr   = "0.0.0.0"
)
View Source
const (
	SequenceNodeID  = "/sequence/node/"
	SequenceRangeID = "/sequence/range/"
	SequenceTableID = "/sequence/table/"
	SequencePeerID  = "/sequence/peer/"
	SequenceDBID    = "/sequence/db/"
	SequenceIndexID = "/sequence/index/"
)

ids sequence key for etcd

View Source
const (
	PrefixLock        = "/lock/"
	PrefixLockCluster = "/lock/_cluster/"
	PrefixNode        = "/node/"
	PrefixNodeTTL     = "/ttl/node/"
	PrefixTable       = "/table/"
	PrefixRange       = "/range/"
	PrefixDataBase    = "/db/"
)
View Source
const (
	ConfAutoSplit = "/config/auto_split"
	ConfFailOver  = "/config/fail_over"
	ConfBalanced  = "/config/balanced"
)
View Source
const ClusterCleanJobKey = "/cluster/cleanjob"

when master runing clean job , it will set value to this key, when other got key , now time less than this they will skip this job

Variables

This section is empty.

Functions

func DBKey

func DBKey(id uint64) string

func DBKeyName

func DBKeyName(name string) string

func DBKeys

func DBKeys(id uint64, name string) (dbKey, nameKey string)

func Err

func Err(e error) *mspb.ResponseHeader

func GetBuildTime

func GetBuildTime() string

func GetBuildVersion

func GetBuildVersion() string

func GetCommitID

func GetCommitID() string

func InitConfig

func InitConfig(path string)

func InitMonitor

func InitMonitor()

func LoadConfig

func LoadConfig(conf *Config, path string)

func LockCluster

func LockCluster() string

func LockDBKey

func LockDBKey(dbID uint64) string

func LockTableKey

func LockTableKey(dbID, tableID uint64) string

func Monitor

func Monitor() monitoring.Monitor

func NodeKey

func NodeKey(nodeID uint64) string

func NodeTTLKey

func NodeTTLKey(nodeID uint64) string

func OK

func OK() *mspb.ResponseHeader

func RangeKey

func RangeKey(tableID, rangeID uint64) string

func RangeKeyPre

func RangeKeyPre(tableID uint64) string

func SequenceDocument

func SequenceDocument(dbID, tableID uint64) string

func SetConfigVersion

func SetConfigVersion(bv, bt, ci string)

func TableKey

func TableKey(dbID, tableID uint64) string

func TableKeyPre

func TableKeyPre(dbID uint64) string

Types

type Config

type Config struct {
	Global  *GlobalCfg `toml:"global,omitempty" json:"global"`
	Masters Masters    `toml:"masters,omitempty" json:"masters"`
}

func Conf

func Conf() *Config

func (*Config) CurrentByMasterNameDomainIp

func (config *Config) CurrentByMasterNameDomainIp(masterName string) error

CurrentByMasterNameDomainIp find this machine domain.The main purpose of this function is to find the master from from multiple masters and set it‘s Field:self to true. The only criterion for judging is: Is the IP address the same with one of the masters?

func (*Config) GetEmbed

func (config *Config) GetEmbed() (*embed.Config, error)

GetEmbed will get or generate the etcd configuration

func (*Config) Validate

func (config *Config) Validate() error

type GlobalCfg

type GlobalCfg struct {
	Name           string  `toml:"name,omitempty" json:"name"`
	Log            string  `toml:"log,omitempty" json:"log"`
	Data           string  `toml:"data,omitempty" json:"data"`
	Level          string  `toml:"level,omitempty" json:"level"`
	Signkey        string  `toml:"signkey,omitempty" json:"signkey"`
	ClusterID      uint64  `toml:"cluster_id,omitempty" json:"cluster_id"`
	ReplicaNum     int     `toml:"replica_num,omitempty" json:"replica_num"`
	ScheduleSecond int     `toml:"schedule_second,omitempty" json:"schedule_second"`
	PeerDownSecond int     `toml:"peer_down_second,omitempty" json:"peer_down_second"`
	MemoryRatio    float64 `toml:"memory_ratio,omitempty" json:"memory_ratio"`

	MonitorEnable bool   `toml:"monitor_enable,omitempty" json:"monitor_enable"`
	Monitor       string `toml:"monitor,omitempty" json:"monitor"`
	PushGateway   string `toml:"push_gateway,omitempty" json:"push_gateway"`
	PushInterval  int    `toml:"push_interval,omitempty" json:"push_interval"`
}

type MasterCfg

type MasterCfg struct {
	Name           string `toml:"name,omitempty" json:"name"`
	Address        string `toml:"address,omitempty" json:"address"`
	ApiPort        uint16 `toml:"api_port,omitempty" json:"api_port"`
	EtcdPort       uint16 `toml:"etcd_port,omitempty" json:"etcd_port"`
	EtcdPeerPort   uint16 `toml:"etcd_peer_port,omitempty" json:"etcd_peer_port"`
	EtcdClientPort uint16 `toml:"etcd_client_port,omitempty" json:"etcd_client_port"`
	Self           bool   `json:"-"`
	PprofPort      uint16 `toml:"pprof_port,omitempty" json:"pprof_port"`
}

func (*MasterCfg) ApiUrl

func (m *MasterCfg) ApiUrl() string

type Masters

type Masters []*MasterCfg

func (Masters) ClientAddress

func (ms Masters) ClientAddress() []string

new client use this function to get client urls

func (Masters) Self

func (ms Masters) Self() *MasterCfg

type ProtoReq

type ProtoReq interface {
	Marshal() (dAtA []byte, err error)
	Unmarshal(dAtA []byte) error
	GetHeader() *mspb.RequestHeader
}

type ProtoResp

type ProtoResp interface {
	Marshal() (dAtA []byte, err error)
	Unmarshal(dAtA []byte) error
	GetHeader() *mspb.ResponseHeader
}

type TableProperty

type TableProperty struct {
	Columns []*basepb.Column `json:"columns"`
	Indexes []*basepb.Index  `json:"indexes"`
}

Directories

Path Synopsis
pkg

Jump to

Keyboard shortcuts

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