metadata

package
v0.0.0-...-49e5460 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2019 License: MIT Imports: 8 Imported by: 0

Documentation

Index

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 NewDatabase(name string) *Database

func (*Database) UnmarshalJSON

func (d *Database) UnmarshalJSON(data []byte) error

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

type Datasource struct {
	ID   int64  `json:"_id"`
	Name string `json:"name"`
}

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 NewDatastore(name string) *Datastore

func (*Datastore) UnmarshalJSON

func (d *Datastore) UnmarshalJSON(data []byte) error

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 (*DatastoreShardReplicaSet) GetByID

func (*DatastoreShardReplicaSet) GetMaster

func (*DatastoreShardReplicaSet) GetSlave

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 NewMeta

func NewMeta() *Meta

func (*Meta) ListDatabases

func (m *Meta) ListDatabases() []string

TODO: more than just names?

func (*Meta) UnmarshalJSON

func (m *Meta) UnmarshalJSON(data []byte) error

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"`
}

Jump to

Keyboard shortcuts

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