models

package
v0.0.0-...-034a78d Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrTooManyFields = errors.New("too many fields")

ErrTooManyFields is the error returned by memory-database when writes exceed the max limit of fields.

View Source
var ErrTooManyTagKeys = errors.New("too many tag keys")

ErrTooManyTagKeys is the error returned by memory-database when writes exceed the max limit of tag keys.

View Source
var ErrTooManyTags = errors.New("too many tags")

ErrTooManyTags is the error returned by memory-database when writes exceed the max limit of tag identifiers.

View Source
var ErrWrongFieldType = errors.New("field type is wrong")

ErrWrongFieldType is the error returned by memory-database when field-type of new point is different from the type before.

Functions

This section is empty.

Types

type ActiveNode

type ActiveNode struct {
	Node       Node  `json:"node"`
	OnlineTime int64 `json:"onlineTime"` // node online time(millisecond)
}

ActiveNode represents active node include online time

type BrokerReplicaState

type BrokerReplicaState struct {
	ReportTime int64          `json:"reportTime"` // broker report state's time(millisecond)
	Replicas   []ReplicaState `json:"replicas"`   // replica state list under this broker
}

BrokerReplicaState represents the replica state list of the broker

type CreateShardTask

type CreateShardTask struct {
	Database    string             `json:"database"`
	ShardIDs    []int32            `json:"shardIDs"`
	ShardOption option.ShardOption `json:"shardOption"`
}

CreateShardTask represents create shard task param

func (CreateShardTask) Bytes

func (t CreateShardTask) Bytes() []byte

Bytes returns create shard task binary data using json

type Database

type Database struct {
	Name     string            `json:"name"`
	Clusters []DatabaseCluster `json:"clusters"`
}

Database defines database config, database can include multi-cluster

type DatabaseCluster

type DatabaseCluster struct {
	Name          string             `json:"name"`
	NumOfShard    int                `json:"numOfShard"`
	ReplicaFactor int                `json:"replicaFactor"`
	ShardOption   option.ShardOption `json:"shardOption"`
}

DatabaseCluster represents database's storage cluster config

type Master

type Master struct {
	Node      Node  `json:"node"`
	ElectTime int64 `json:"electTime"`
}

Master represents master basic info

type Node

type Node struct {
	IP   string `json:"ip"`
	Port uint16 `json:"port"`
}

Node represents the basic info of server

func (*Node) Indicator

func (n *Node) Indicator() string

Indicator returns return node indicator's string

type Replica

type Replica struct {
	Replicas []int `json:"replicas"`
}

Replica defines replica list for spec shard of database

type ReplicaState

type ReplicaState struct {
	Cluster      string `json:"cluster"`      // cluster which storing database
	Database     string `json:"database"`     // database name
	ShardID      int32  `json:"shardID"`      // shard id
	TO           Node   `json:"to"`           // target storage node for database's shard
	WriteIndex   int64  `json:"writeIndex"`   // wal write index
	ReplicaIndex int64  `json:"replicaIndex"` // replica index for current replicator's channel
	CommitIndex  int64  `json:"commitIndex"`  // commit index
}

ReplicaState represents the status of replicator's channel

func (ReplicaState) Pending

func (r ReplicaState) Pending() int64

Pending returns the num. of pending which it need replica msg

func (ReplicaState) ShardIndicator

func (r ReplicaState) ShardIndicator() string

ShardIndicator returns shard indicator based on cluster/database/shard id

type ShardAssignment

type ShardAssignment struct {
	Config DatabaseCluster  `json:"cluster"`
	Nodes  map[int]*Node    `json:"nodes"`
	Shards map[int]*Replica `json:"shards"`
}

ShardAssignment defines shard assignment for database

func NewShardAssignment

func NewShardAssignment() *ShardAssignment

NewShardAssignment returns empty shard assignment instance

func (*ShardAssignment) AddReplica

func (s *ShardAssignment) AddReplica(shardID int, replicaID int)

AddReplica adds replica id to replica list of spec shard

type StorageCluster

type StorageCluster struct {
	Name   string       `json:"name"`
	Config state.Config `json:"config"`
}

StorageCluster represents config of storage cluster

type StorageState

type StorageState struct {
	Name        string                 `json:"name"`
	ActiveNodes map[string]*ActiveNode `json:"activeNodes"`
}

StorageState represents storage cluster node state. NOTICE: it is not safe for concurrent use.

func NewStorageState

func NewStorageState() *StorageState

NewStorageState creates storage cluster state

func (*StorageState) AddActiveNode

func (s *StorageState) AddActiveNode(node *ActiveNode)

AddActiveNode adds a node into active node list

func (*StorageState) GetActiveNodes

func (s *StorageState) GetActiveNodes() []*ActiveNode

GetActiveNodes returns all active nodes

func (*StorageState) RemoveActiveNode

func (s *StorageState) RemoveActiveNode(node string)

RemoveActiveNode removes a node from active node list

type Tag

type Tag struct {
	// tag-key
	Key string
	// tag-value
	Value string
}

Tag is the key/value tag pair of a metric point.

func NewTags

func NewTags(tagStr string) (theTags []Tag)

NewTags returns a Tag list from string.

type User

type User struct {
	UserName string `toml:"username" json:"UserName"`
	Password string `toml:"password" json:"Password"`
}

User represents user model

Jump to

Keyboard shortcuts

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