Documentation ¶
Index ¶
- type Collection
- func (c *Collection) FunctionDefaultRecord(record record.Record) error
- func (c *Collection) GetField(nameParts []string) *storagenodemetadata.CollectionField
- func (c *Collection) GetFieldByName(name string) *storagenodemetadata.CollectionField
- func (c *Collection) IsSharded() bool
- func (c *Collection) IsValidProjection(name string) bool
- func (c *Collection) UnmarshalJSON(data []byte) error
- type CollectionKeyspace
- type CollectionKeyspacePartition
- type Database
- type DatabaseDatastore
- type Datasource
- type DatasourceInstance
- type DatasourceInstanceShardInstance
- type Datastore
- type DatastoreSet
- type DatastoreShard
- type DatastoreShardReplica
- type DatastoreShardReplicaSet
- func (d *DatastoreShardReplicaSet) AddReplica(r *DatastoreShardReplica)
- func (d *DatastoreShardReplicaSet) GetByID(id int64) *DatastoreShardReplica
- func (d *DatastoreShardReplicaSet) GetMaster() *DatastoreShardReplica
- func (d *DatastoreShardReplicaSet) GetSlave() *DatastoreShardReplica
- func (d *DatastoreShardReplicaSet) IterReplica() chan *DatastoreShardReplica
- type DatastoreVShard
- type DatastoreVShardInstance
- type Meta
- type ProvisionState
- type StorageNode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Collection ¶
type Collection struct { ID int64 `json:"_id"` Name string `json:"name"` Fields map[string]*storagenodemetadata.CollectionField `json:"fields"` Indexes map[string]*storagenodemetadata.CollectionIndex `json:"indexes"` // Link directly to primary index (for convenience) PrimaryIndex *storagenodemetadata.CollectionIndex `json:"-"` // TODO: there will be potentially many partitions, it might be worthwhile // to wrap this list in a struct to handle the searching etc. Keyspaces []*CollectionKeyspace `json:"keyspaces"` ProvisionState ProvisionState `json:"provision_state"` // contains filtered or unexported fields }
func NewCollection ¶
func NewCollection(name string) *Collection
func (*Collection) FunctionDefaultRecord ¶
func (c *Collection) FunctionDefaultRecord(record record.Record) error
func (*Collection) GetField ¶
func (c *Collection) GetField(nameParts []string) *storagenodemetadata.CollectionField
func (*Collection) GetFieldByName ¶
func (c *Collection) GetFieldByName(name string) *storagenodemetadata.CollectionField
func (*Collection) IsSharded ¶
func (c *Collection) IsSharded() bool
func (*Collection) IsValidProjection ¶
func (c *Collection) IsValidProjection(name string) bool
TODO: rename? This is actually "is this a valid subfield"
func (*Collection) UnmarshalJSON ¶
func (c *Collection) UnmarshalJSON(data []byte) error
type CollectionKeyspace ¶
type CollectionKeyspace struct { ID int64 `json:"_id,omitempty"` Hash sharding.HashMethod `json:"hash_method"` HashFunc sharding.HashFunc `json:"-"` ShardKey []string `json:"shard_key"` // dot-split version (for perf, since we do it a LOT) ShardKeySplit [][]string `json:"-"` Partitions []*CollectionKeyspacePartition `json:"partitions"` }
func (*CollectionKeyspace) GetKeyspacePartition ¶
func (c *CollectionKeyspace) GetKeyspacePartition(k uint64) *CollectionKeyspacePartition
GetKeyspacePartition will return the KeyspacePartition for the given key `k`
func (*CollectionKeyspace) UnmarshalJSON ¶
func (c *CollectionKeyspace) UnmarshalJSON(data []byte) error
type CollectionKeyspacePartition ¶
type CollectionKeyspacePartition struct { ID int64 `json:"_id,omitempty"` StartId uint64 `json:"start_id"` EndId uint64 `json:"end_id,omitempty"` Shard sharding.ShardMethod `json:"shard_method"` ShardFunc sharding.ShardFunc `json:"-"` DatastoreVShardIDs []int64 `json:"datastore_vshard_ids"` // map of datastore_id -> vshard DatastoreVShards map[int64]*DatastoreVShard `json:"-"` }
func (*CollectionKeyspacePartition) UnmarshalJSON ¶
func (p *CollectionKeyspacePartition) UnmarshalJSON(data []byte) error
type Database ¶
type Database struct { ID int64 `json:"_id"` Name string `json:"name"` Datastores []*DatabaseDatastore `json:"datastores"` // We have a "set" struct to encapsulate datastore selection // This is the representation of the database_datastore linking table DatastoreSet *DatastoreSet `json:"-"` // mapping of all collections Collections map[string]*Collection `json:"collections"` ProvisionState ProvisionState `json:"provision_state"` }
func NewDatabase ¶
func (*Database) UnmarshalJSON ¶
type DatabaseDatastore ¶
type DatabaseDatastore struct { ID int64 `json:"_id"` // TODO: elsewhere? This data is pulled in from a linking table-- but is associated Read bool `json:"read"` Write bool `json:"write"` // TODO: use once we support more than one datastore per database Required bool `json:"required"` DatastoreID int64 `json:"datastore_id"` Datastore *Datastore `json:"-"` ProvisionState ProvisionState `json:"provision_state"` }
We need to have linking from database -> datastore, and some of the metadata is associated to just that link
type Datasource ¶
TODO: type switch this? name here should be the type of the underlying storage node interface
type DatasourceInstance ¶
type DatasourceInstance struct { ID int64 `json:"_id"` Name string `json:"name"` // TODO remove ID? It is a child in the meta-- so no need to have the ID // TODO: not sure how we want to link these StorageNodeID int64 `json:"storage_node_id"` // TODO: remove? We need some reverse linking since we need to send to the actual storagenode at some point StorageNode *StorageNode `json:"-"` // TODO: actual config Config map[string]interface{} `json:"config,omitempty"` // All of the shard instances it has ShardInstances map[int64]*DatasourceInstanceShardInstance `json:"shard_instances"` ProvisionState ProvisionState `json:"provision_state"` }
func NewDatasourceInstance ¶
func NewDatasourceInstance(name string) *DatasourceInstance
func (*DatasourceInstance) GetBaseURL ¶
func (d *DatasourceInstance) GetBaseURL() string
func (*DatasourceInstance) GetURL ¶
func (d *DatasourceInstance) GetURL() string
type DatasourceInstanceShardInstance ¶
type DatasourceInstanceShardInstance struct { ID int64 `json:"_id"` // TODO: remove? Name string `json:"name,omitempty"` DatasourceVShardInstanceID int64 `json:"datasource_vshard_instance_id"` ProvisionState ProvisionState `json:"provision_state"` }
type Datastore ¶
type Datastore struct { ID int64 `json:"_id"` Name string `json:"name"` VShards map[string]*DatastoreVShard `json:"vshards"` // map of instance -> shard Shards map[int64]*DatastoreShard `json:"shards"` ProvisionState ProvisionState `json:"provision_state"` }
func NewDatastore ¶
func (*Datastore) UnmarshalJSON ¶
type DatastoreSet ¶
type DatastoreSet struct { Read []*DatabaseDatastore `json:"read"` Write *DatabaseDatastore `json:"write"` }
A set of datastores associated with a specific database
func NewDatastoreSet ¶
func NewDatastoreSet() *DatastoreSet
func (*DatastoreSet) ToSlice ¶
func (d *DatastoreSet) ToSlice() []*DatabaseDatastore
type DatastoreShard ¶
type DatastoreShard struct { ID int64 `json:"_id"` Name string `json:"name"` Instance int64 `json:"shard_instance"` // TODO: have one list for serialization Replicas *DatastoreShardReplicaSet `json:"replicas"` // Internal fields DatastoreID int64 `json:"-"` ProvisionState ProvisionState `json:"provision_state"` }
type DatastoreShardReplica ¶
type DatastoreShardReplica struct { ID int64 `json:"_id"` DatasourceInstanceID int64 `json:"datasource_instance_id"` DatasourceInstance *DatasourceInstance `json:"-"` Master bool `json:"master"` ProvisionState ProvisionState `json:"provision_state"` }
type DatastoreShardReplicaSet ¶
type DatastoreShardReplicaSet struct { Masters []*DatastoreShardReplica `json:"masters"` Slaves []*DatastoreShardReplica `json:"slaves"` // contains filtered or unexported fields }
func NewDatastoreShardReplicaSet ¶
func NewDatastoreShardReplicaSet() *DatastoreShardReplicaSet
func (*DatastoreShardReplicaSet) AddReplica ¶
func (d *DatastoreShardReplicaSet) AddReplica(r *DatastoreShardReplica)
func (*DatastoreShardReplicaSet) GetByID ¶
func (d *DatastoreShardReplicaSet) GetByID(id int64) *DatastoreShardReplica
func (*DatastoreShardReplicaSet) GetMaster ¶
func (d *DatastoreShardReplicaSet) GetMaster() *DatastoreShardReplica
func (*DatastoreShardReplicaSet) GetSlave ¶
func (d *DatastoreShardReplicaSet) GetSlave() *DatastoreShardReplica
func (*DatastoreShardReplicaSet) IterReplica ¶
func (d *DatastoreShardReplicaSet) IterReplica() chan *DatastoreShardReplica
Iterate over all replicas in the set
type DatastoreVShard ¶
type DatastoreVShard struct { ID int64 `json:"_id"` Count int64 `json:"count"` Name string `json:"name"` // TODO: change to a map of instance -> shard Shards []*DatastoreVShardInstance `json:"shards"` DatabaseID int64 `json:"database_id"` // Internal fields DatastoreID int64 `json:"-"` ProvisionState ProvisionState `json:"provision_state"` }
type DatastoreVShardInstance ¶
type DatastoreVShardInstance struct { ID int64 `json:"_id"` Instance int64 `json:"shard_instance"` DatastoreShardInstance int64 `json:"datastore_shard_instance"` DatastoreShard *DatastoreShard `json:"-"` // Internal fields DatastoreVShardID int64 `json:"-"` ProvisionState ProvisionState `json:"provision_state"` }
type Meta ¶
type Meta struct { Nodes map[int64]*StorageNode `json:"storage_node"` DatasourceInstance map[int64]*DatasourceInstance `json:"-"` Datastore map[int64]*Datastore `json:"datastores"` // TODO: remove? or make private? DatastoreShards map[int64]*DatastoreShard `json:"-"` DatastoreVShards map[int64]*DatastoreVShard `json:"-"` DatastoreVShardInstances map[int64]*DatastoreVShardInstance `json:"-"` Fields map[int64]*storagenodemetadata.CollectionField `json:"-"` Collections map[int64]*Collection `json:"-"` FieldTypeRegistry *storagenodemetadata.FieldTypeRegister `json:"field_types"` Databases map[string]*Database `json:"databases"` }
This struct encapsulates the metadata for the router node. In addition to data that we expose, we also use this to solve the import/load problem where we want to load a single object at most once, so we load from the "bottom-up" and reference already loaded objects if they have been, otherwise they get loaded
func (*Meta) UnmarshalJSON ¶
type ProvisionState ¶
type ProvisionState int
const ( Config ProvisionState = iota Provision Validate Active Maintenance // TODO: do we need this? If we don't then we need to have a separate mechanism // to know when something is on the way out Deallocate )
type StorageNode ¶
type StorageNode struct { ID int64 `json:"_id"` Name string `json:"name"` IP net.IP `json:"ip"` Port int `json:"port"` DatasourceInstances map[string]*DatasourceInstance `json:"datasource_instances"` ProvisionState ProvisionState `json:"provision_state"` }