Documentation ¶
Index ¶
- func NewTableFormatter() table.Writer
- type Broker
- type BrokerState
- type Brokers
- type CPUStat
- type ClusterStatus
- type CreateShardTask
- type DataFamilyState
- type Database
- type DatabaseAssignment
- type DatabaseConfig
- type DatabaseFlushTask
- type DatabaseNames
- type Databases
- type Env
- type ExecuteParam
- type FamilyLogReplicaState
- type FamilyState
- type Field
- type Limits
- func (l *Limits) EnableFieldNameLengthCheck() bool
- func (l *Limits) EnableFieldsCheck() bool
- func (l *Limits) EnableMetricNameLengthCheck() bool
- func (l *Limits) EnableMetricsCheck() bool
- func (l *Limits) EnableNamespaceLengthCheck() bool
- func (l *Limits) EnableNamespacesCheck() bool
- func (l *Limits) EnableSeriesCheckForQuery() bool
- func (l *Limits) EnableTagNameLengthCheck() bool
- func (l *Limits) EnableTagValueLengthCheck() bool
- func (l *Limits) EnableTagsCheck() bool
- func (l *Limits) GetSeriesLimit(namespace, metricName string) uint32
- func (l *Limits) TOML() string
- type LogicDatabase
- type Master
- type MemoryDatabaseState
- type MemoryStat
- type Metadata
- type Monitor
- type Node
- type NodeID
- type NodeStateType
- type NodeStats
- type OperatorStats
- type PhysicalPlan
- type Points
- type Replica
- type ReplicaPeerState
- type ReplicaState
- type ReplicatorState
- type Request
- type ResultSet
- type Router
- type Series
- type SeriesStats
- type ShardAssignment
- type ShardID
- type ShardState
- type ShardStateType
- type StageStats
- type StateField
- type StateMachineInfo
- type StateMetric
- type StatefulNode
- type StatelessNode
- type StatelessNodes
- type Stats
- type Storage
- type StorageState
- func (s *StorageState) DropDatabase(name string)
- func (s *StorageState) LeadersOnNode(nodeID NodeID) map[string][]ShardID
- func (s *StorageState) NodeOffline(nodeID NodeID)
- func (s *StorageState) NodeOnline(node StatefulNode)
- func (s *StorageState) ReplicasOnNode(nodeID NodeID) map[string][]ShardID
- func (s *StorageState) String() string
- type Storages
- type SuggestResult
- type SystemStat
- type TableFormatter
- type Target
- type TaskState
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewTableFormatter ¶
NewTableFormatter creates a writer for table format.
Types ¶
type Broker ¶ added in v0.2.4
type Broker struct { config.BrokerCluster Status ClusterStatus `json:"status"` }
Storage represents storage config and state.
type BrokerState ¶ added in v0.2.4
type BrokerState struct { Name string `json:"name"` // ref Namespace LiveNodes map[string]StatelessNode `json:"liveNodes"` }
BrokerState represents broker cluster state. NOTICE: it is not safe for concurrent use.
func NewBrokerState ¶ added in v0.2.4
func NewBrokerState(name string) *BrokerState
func (*BrokerState) GetLiveNodes ¶ added in v0.2.4
func (b *BrokerState) GetLiveNodes() (rs []StatelessNode)
GetLiveNodes returns all live node list.
func (*BrokerState) NodeOffline ¶ added in v0.2.4
func (b *BrokerState) NodeOffline(nodeID string)
NodeOffline removes a offline node from live node list.
func (*BrokerState) NodeOnline ¶ added in v0.2.4
func (b *BrokerState) NodeOnline(nodeID string, node StatelessNode)
NodeOnline adds a live node into node list.
type CPUStat ¶
type CPUStat struct { User float64 `json:"user"` System float64 `json:"system"` Idle float64 `json:"idle"` Nice float64 `json:"nice"` Iowait float64 `json:"iowait"` Irq float64 `json:"irq"` Softirq float64 `json:"softirq"` Steal float64 `json:"steal"` }
CPUStat represents the amounts of time the CPU has spent performing different kinds of work.
type ClusterStatus ¶ added in v0.2.4
type ClusterStatus int
ClusterStatus represents current cluster config status.
const ( ClusterStatusUnknown ClusterStatus = iota ClusterStatusInitialize ClusterStatusReady )
func (ClusterStatus) MarshalJSON ¶ added in v0.2.4
func (s ClusterStatus) MarshalJSON() ([]byte, error)
MarshalJSON encodes storage status.
func (ClusterStatus) String ¶ added in v0.2.4
func (s ClusterStatus) String() string
String returns the string value of StorageStatus.
func (*ClusterStatus) UnmarshalJSON ¶ added in v0.2.4
func (s *ClusterStatus) UnmarshalJSON(value []byte) error
UnmarshalJSON decodes storage status.
type CreateShardTask ¶
type CreateShardTask struct { DatabaseName string `json:"databaseName"` // database's name ShardIDs []ShardID `json:"shardIDs"` // shard ids DatabaseOption option.DatabaseOption `json:"databaseOption"` // time series database }
CreateShardTask represents the create shard task's param
func (*CreateShardTask) Bytes ¶
func (t *CreateShardTask) Bytes() []byte
Bytes returns the creation shard task's binary data using json
type DataFamilyState ¶
type DataFamilyState struct { ShardID ShardID `json:"shardId"` FamilyTime string `json:"familyTime"` AckSequences map[int32]int64 `json:"ackSequences"` ReplicaSequences map[int32]int64 `json:"replicaSequences"` MemoryDatabases []MemoryDatabaseState `json:"memoryDatabases"` }
DataFamilyState represents the state of data family.
type Database ¶
type Database struct { Name string `json:"name" validate:"required"` // database's name Storage string `json:"storage" validate:"required"` // storage cluster's name NumOfShard int `json:"numOfShard" validate:"gt=0"` // num. of shard ReplicaFactor int `json:"replicaFactor" validate:"gt=0"` // replica refactor Option *option.DatabaseOption `json:"option"` // time series database option Desc string `json:"desc,omitempty"` }
Database defines database config.
type DatabaseAssignment ¶
type DatabaseAssignment struct { ShardAssignment *ShardAssignment `json:"shardAssignment"` Option *option.DatabaseOption `json:"option"` }
type DatabaseConfig ¶ added in v0.1.1
type DatabaseConfig struct { ShardIDs []ShardID `toml:"shardIDs" json:"shardIDs"` Option *option.DatabaseOption `toml:"option" json:"option"` }
DatabaseConfig represents a database configuration about config and families
type DatabaseFlushTask ¶
type DatabaseFlushTask struct {
DatabaseName string `json:"databaseName"` // database's name
}
DatabaseFlushTask represents the database flush task's param
func (DatabaseFlushTask) Bytes ¶
func (t DatabaseFlushTask) Bytes() []byte
Bytes returns the database flush task's binary data using json
type DatabaseNames ¶
type DatabaseNames []string
DatabaseNames represents the database name list.
func (DatabaseNames) ToTable ¶
func (dbs DatabaseNames) ToTable() (rows int, tableStr string)
ToTable returns database name list as table if it has value, else return empty string.
type ExecuteParam ¶
type ExecuteParam struct { Database string `form:"db" json:"db"` SQL string `form:"sql" json:"sql" binding:"required"` }
ExecuteParam represents lin query language executor's param.
type FamilyLogReplicaState ¶
type FamilyLogReplicaState struct { ShardID ShardID `json:"shardId"` FamilyTime string `json:"familyTime"` Leader NodeID `json:"leader"` Append int64 `json:"append"` Replicators []ReplicaPeerState `json:"replicators"` }
FamilyLogReplicaState represents the family's log replica state.
type FamilyState ¶
type FamilyState struct { Database string `json:"database"` Shard ShardState `json:"shard"` FamilyTime int64 `json:"familyTime"` }
FamilyState represents current state of shard's family.
type Limits ¶ added in v0.2.4
type Limits struct { // Write limits MaxNamespaces uint32 `toml:"max-namespaces"` MaxNamespaceLength int `toml:"max-namespace-length"` MaxMetrics uint32 `toml:"max-metrics"` MaxMetricNameLength int `toml:"max-metric-name-length"` MaxFieldNameLength int `toml:"max-field-name-length"` MaxFieldsPerMetric int32 `toml:"max-fields-per-metric"` MaxTagNameLength int `toml:"max-tag-name-length"` MaxTagValueLength int `toml:"max-tag-value-length"` MaxTagsPerMetric int `toml:"max-tags-per-metric"` MaxSeriesPerMetric uint32 `toml:"max-series-per-metric"` // max series limit for metric Metrics map[string]uint32 `toml:"metrics"` // Read Limits MaxSeriesPerQuery int `toml:"max-series-per-query"` }
Limits represents all the limit for database level; can be used to describe global default limits, or per-database limits vis toml config.
func NewDefaultLimits ¶ added in v0.2.4
func NewDefaultLimits() *Limits
NewDefaultLimits creates a default limits.
func (*Limits) EnableFieldNameLengthCheck ¶ added in v0.2.4
EnableFieldNameLengthCheck returns if need check field name's length.
func (*Limits) EnableFieldsCheck ¶ added in v0.2.4
EnableFieldsCheck returns if need limit num. of fields for metric.
func (*Limits) EnableMetricNameLengthCheck ¶ added in v0.2.4
EnableMetricNameLengthCheck returns if need check metric name's length.
func (*Limits) EnableMetricsCheck ¶ added in v0.2.4
EnableMetricsCheck returns if need limit num. of metrics.
func (*Limits) EnableNamespaceLengthCheck ¶ added in v0.2.4
EnableNamespaceLengthCheck returns if need check namespace's length.
func (*Limits) EnableNamespacesCheck ¶ added in v0.2.4
EnableNamespacesCheck returns if need limit num. of namepsaces.
func (*Limits) EnableSeriesCheckForQuery ¶ added in v0.2.4
EnableSereisCheckForQuery returns if need check num. of series for query
func (*Limits) EnableTagNameLengthCheck ¶ added in v0.2.4
EnableTagNameLengthCheck returns if need check tag name's length.
func (*Limits) EnableTagValueLengthCheck ¶ added in v0.2.4
EnableTagValueLengthCheck returns if need check tag value's length.
func (*Limits) EnableTagsCheck ¶ added in v0.2.4
EnableTagsCheck returns if need limit num. of tags for metric.
func (*Limits) GetSeriesLimit ¶ added in v0.2.4
GetSeriesLimit returns the limit by given namespace/metric name.
type LogicDatabase ¶ added in v0.2.4
type LogicDatabase struct { Name string `json:"name" validate:"required"` // database's name Routers []Router `json:"routers" validate:"required"` // database router Desc string `json:"desc,omitempty"` }
LogicDatabase defines database logic config, database can include multi-cluster.
type Master ¶
type Master struct { Node *StatelessNode `json:"node"` ElectTime int64 `json:"electTime"` }
Master represents master basic info.
type MemoryDatabaseState ¶
type MemoryDatabaseState struct { State string `json:"state"` Uptime time.Duration `json:"uptime"` MemSize int64 `json:"memSize"` NumOfMetrics int `json:"numOfMetrics"` NumOfSeries int `json:"numOfSeries"` }
MemoryDatabaseState represents the state of memory database.
type MemoryStat ¶
type MemoryStat struct { // Total amount of RAM on this system Total uint64 `json:"total"` // RAM used by programs // This value is computed from the kernel specific values. Used uint64 `json:"used"` // Percentage of RAM used by programs // This value is computed from the kernel specific values. UsedPercent float64 `json:"usedPercent"` }
MemoryStat represents the memory usage statistics in system
type Metadata ¶
type Metadata struct { Type string `json:"type"` Values interface{} `json:"values"` }
Metadata represents metadata query result model
type Monitor ¶ added in v0.2.4
type Monitor struct {
Database string `json:"database"`
}
monitor represents self-monitor vars.
type Node ¶
type Node interface { // Indicator returns node indicator's string. Indicator() string // HTTPAddress returns address for http. HTTPAddress() string }
Node represents the node info in cluster(broker/storage).
type NodeID ¶
type NodeID int
NodeID represents node identifier.
const NoLeader NodeID = -1
func ParseNodeID ¶
ParseNodeID parses node id from string value.
type NodeStateType ¶
type NodeStateType int
NodeStateType represents node state type
const ( NodeOnline NodeStateType = iota + 1 NodeOffline )
type NodeStats ¶ added in v0.2.4
type NodeStats struct { Node string `json:"node"` WaitCost int64 `json:"waitCost,omitempty"` // wait intermediate or leaf response duration WaitStart int64 `json:"waitStart,omitempty"` WaitEnd int64 `json:"waitEnd,omitempty"` NetPayload int64 `json:"netPayload,omitempty"` TotalCost int64 `json:"totalCost"` Start int64 `json:"start"` End int64 `json:"end"` Stages []*StageStats `json:"stages,omitempty"` Children []*NodeStats `json:"children,omitempty"` }
NodeStats represents query stats of node.
type OperatorStats ¶
type OperatorStats struct { Identifier string `json:"identifier"` Start int64 `json:"start"` End int64 `json:"end"` Cost int64 `json:"cost"` Stats interface{} `json:"stats,omitempty"` ErrMsg string `json:"errMsg,omitempty"` }
OperatorStats represents the stats of operator.
type PhysicalPlan ¶
type PhysicalPlan struct { Database string `json:"database"` // database name Targets []*Target `json:"targets"` Receivers []string `json:"receivers"` }
PhysicalPlan represents the distribution query's physical plan
func (*PhysicalPlan) AddReceiver ¶ added in v0.2.4
func (t *PhysicalPlan) AddReceiver(receiver string)
AddReceiver adds a receiver.
func (*PhysicalPlan) AddTarget ¶ added in v0.2.4
func (t *PhysicalPlan) AddTarget(target *Target)
AddTarget adds a target.
func (*PhysicalPlan) Validate ¶ added in v0.2.4
func (t *PhysicalPlan) Validate() error
Validate checks the plan if valid.
type Replica ¶
type Replica struct {
Replicas []NodeID `json:"replicas"`
}
Replica defines replica list for spec shard of database.
type ReplicaPeerState ¶
type ReplicaPeerState struct { Replicator string `json:"replicator"` ReplicatorType string `json:"replicatorType"` Consume int64 `json:"consume"` ACK int64 `json:"ack"` Pending int64 `json:"pending"` State ReplicatorState `json:"state"` StateErrMsg string `json:"stateErrMsg"` }
ReplicaPeerState represents current wal replica peer state.
type ReplicaState ¶
type ReplicaState struct { Database string `json:"database"` ShardID ShardID `json:"shardId"` Leader NodeID `json:"leader"` Follower NodeID `json:"follower"` FamilyTime int64 `json:"familyTime"` }
ReplicaState represents the relationship for a replica.
func (ReplicaState) String ¶
func (r ReplicaState) String() string
String returns the string value of ReplicaState.
type ReplicatorState ¶
type ReplicatorState int
ReplicatorState represents the replicator channel state.
const ( ReplicatorUnknownState ReplicatorState = iota ReplicatorInitState ReplicatorReadyState ReplicatorFailureState )
func (ReplicatorState) MarshalJSON ¶
func (s ReplicatorState) MarshalJSON() ([]byte, error)
MarshalJSON encodes replicator status.
func (ReplicatorState) String ¶
func (s ReplicatorState) String() string
String returns the string value of ReplicatorState.
func (*ReplicatorState) UnmarshalJSON ¶
func (s *ReplicatorState) UnmarshalJSON(value []byte) error
UnmarshalJSON decodes storage status.
type Request ¶
type Request struct { Entry string `json:"entry"` RequestID string `json:"requestId"` DB string `json:"db"` SQL string `json:"sql"` Start int64 `json:"start"` }
Request represents lin query langage execute request.
func NewRequest ¶ added in v0.2.4
NewRequest creates a request instance.
type ResultSet ¶
type ResultSet struct { MetricName string `json:"metricName,omitempty"` GroupBy []string `json:"groupBy,omitempty"` Fields []string `json:"fields,omitempty"` StartTime int64 `json:"startTime,omitempty"` EndTime int64 `json:"endTime,omitempty"` Interval int64 `json:"interval,omitempty"` Series []*Series `json:"series,omitempty"` Stats *NodeStats `json:"stats,omitempty"` }
ResultSet represents the query result set
type Router ¶ added in v0.2.4
type Router struct { Key string `json:"key" validate:"required"` // routing key Values []string `json:"values" validate:"required"` // routing values Broker string `json:"broker" validate:"required"` // target broker Database string `json:"database,omitempty"` // target database }
Router represents the router of database.
type Series ¶
type Series struct { Tags map[string]string `json:"tags,omitempty"` Fields map[string]map[int64]float64 `json:"fields,omitempty"` TagValues string `json:"-"` // return series in order by tag values }
Series represents one time series for metric.
type SeriesStats ¶
type SeriesStats struct {
NumOfSeries uint64 `json:"numOfSeries"`
}
SeriesStats represents the stats for series.
type ShardAssignment ¶
type ShardAssignment struct { Name string `json:"name"` // database's name Shards map[ShardID]*Replica `json:"shards"` // contains filtered or unexported fields }
ShardAssignment defines shard assignment for database.
func NewShardAssignment ¶
func NewShardAssignment(name string) *ShardAssignment
NewShardAssignment returns empty shard assignment instance.
func (*ShardAssignment) AddReplica ¶
func (s *ShardAssignment) AddReplica(shardID ShardID, replicaID NodeID)
AddReplica adds replica id to replica list of spec shard.
func (*ShardAssignment) GetReplicaFactor ¶ added in v0.1.1
func (s *ShardAssignment) GetReplicaFactor() int
GetReplicaFactor returns the factor of replica.
type ShardID ¶
type ShardID int
ShardID represents type for shard id.
func ParseShardID ¶
ParseShardID returns ShardID by given shard string value.
type ShardState ¶
type ShardState struct { ID ShardID `json:"id"` State ShardStateType `json:"state"` Leader NodeID `json:"leader"` Replica Replica `json:"replica"` }
ShardState represents current state of shard.
type ShardStateType ¶
type ShardStateType int
const ( UnknownShard ShardStateType = iota NewShard OnlineShard OfflineShard NonExistentShard )
type StageStats ¶
type StageStats struct { Identifier string `json:"identifier"` Start int64 `json:"start"` End int64 `json:"end"` Cost int64 `json:"cost"` State string `json:"state"` ErrMsg string `json:"errMsg"` Async bool `json:"async"` Operators []*OperatorStats `json:"operators,omitempty"` Children []*StageStats `json:"children"` }
StageStats represents the stats of stage.
type StateField ¶
type StateField struct { Name string `json:"name"` Type string `json:"type"` Value float64 `json:"value"` }
StateField represents internal state value.
type StateMachineInfo ¶
type StateMachineInfo struct { Path string `json:"path"` CreateState func() interface{} `json:"-"` }
StateMachineInfo represents state machine register info.
type StateMetric ¶
type StateMetric struct { Tags map[string]string `json:"tags"` Fields []StateField `json:"fields"` }
StateMetric represents internal state metric.
type StatefulNode ¶
type StatefulNode struct { StatelessNode ID NodeID `json:"id"` }
StatefulNode represents stateful node basic info.
type StatelessNode ¶
type StatelessNode struct { HostIP string `json:"hostIp"` HostName string `json:"hostName"` GRPCPort uint16 `json:"grpcPort,omitempty"` HTTPPort uint16 `json:"httpPort"` Version string `json:"version"` OnlineTime int64 `json:"onlineTime"` // node online time(millisecond) }
StatelessNode represents stateless node basic info.
func (*StatelessNode) HTTPAddress ¶
func (n *StatelessNode) HTTPAddress() string
func (*StatelessNode) Indicator ¶
func (n *StatelessNode) Indicator() string
Indicator returns node indicator's string.
type StatelessNodes ¶
type StatelessNodes []StatelessNode
StatelessNodes represents stateless node list.
func (StatelessNodes) ToTable ¶
func (n StatelessNodes) ToTable() (rows int, tableStr string)
ToTable returns stateless node list as table if it has value, else return empty string.
type Stats ¶
type Stats struct { TotalCost int64 `json:"totalCost"` Min int64 `json:"min"` Max int64 `json:"max"` Count int `json:"count"` Series int `json:"series,omitempty"` }
Stats represents the time stats
type Storage ¶
type Storage struct { config.StorageCluster Status ClusterStatus `json:"status"` }
Storage represents storage config and state.
type StorageState ¶
type StorageState struct { Name string `json:"name"` // ref Namespace LiveNodes map[NodeID]StatefulNode `json:"liveNodes"` // TODO remove?? ShardAssignments map[string]*ShardAssignment `json:"shardAssignments"` // database's name => shard assignment ShardStates map[string]map[ShardID]ShardState `json:"shardStates"` // database's name => shard state }
StorageState represents storage cluster state. NOTICE: it is not safe for concurrent use. TODO: need concurrent safe????
func NewStorageState ¶
func NewStorageState(name string) *StorageState
NewStorageState creates storage cluster state
func (*StorageState) DropDatabase ¶
func (s *StorageState) DropDatabase(name string)
DropDatabase drops shard state/assignment by database's name.
func (*StorageState) LeadersOnNode ¶
func (s *StorageState) LeadersOnNode(nodeID NodeID) map[string][]ShardID
LeadersOnNode returns leaders on this node.
func (*StorageState) NodeOffline ¶
func (s *StorageState) NodeOffline(nodeID NodeID)
NodeOffline removes a offline node from live node list.
func (*StorageState) NodeOnline ¶
func (s *StorageState) NodeOnline(node StatefulNode)
NodeOnline adds a live node into node list.
func (*StorageState) ReplicasOnNode ¶
func (s *StorageState) ReplicasOnNode(nodeID NodeID) map[string][]ShardID
ReplicasOnNode returns replicas on this node.
func (*StorageState) String ¶
func (s *StorageState) String() string
Stringer returns a human readable string
type SuggestResult ¶
type SuggestResult struct {
Values []string `json:"values"`
}
SuggestResult represents the suggest result set
type SystemStat ¶
type SystemStat struct { CPUs int `json:"cpus"` // number of cpu logic core CPUStat *CPUStat `json:"cpuStat,omitempty"` // cpu stat MemoryStat *mem.VirtualMemoryStat `json:"memoryStat,omitempty"` // memory stat DiskUsageStat *disk.UsageStat `json:"diskUsageStat,omitempty"` // disk usage stat }
SystemStat represents the system statistics
type TableFormatter ¶
type TableFormatter interface { // ToTable returns string value/row size for displaying result in terminal. ToTable() (rows int, tableStr string) }
TableFormatter represents table formatter for displaying result in terminal.