Documentation ¶
Overview ¶
Package datastore contains the structs and logic to handle accessing and managing a backend datastore. The datastore contains all network mappings for the nodes participating in the quantum network, as well as global configuration for the network.
The design of the datastore module is to expose a single method that represents accessing a network mapping. This is wrapped in a simple interface to allow for extending quantum to support multiple backends in the future.
The basic architecture is to have an in memory map object that is synchronized in the background. This allows the read only worker threads efficient access to the data, while still ensuring data consistency.
Currently supported datastores:
https://github.com/coreos/etcd (Both v2 and v3 api's)
The data structure itself is as follows:
Key: Private ip of the node Value: json serialized mapping object Etcd Example: quantum/nodes/10.99.0.1 { "machineID": "b8fc945e893cfd55dc6170b6a4f6471d5790fa279e020410f435759ba9e3f0c5", "privateIP": "10.99.0.1", "publicKey": "EZOUpfx4N0LvU8A9\/b5seoUSm7+sOvWr8uE7zRATijU=", "ipv4": "172.18.0.2", "ipv6": "fd00:dead:beef::2", "port": 1099 }
Index ¶
Constants ¶
const ( // ETCDV2Datastore will tell quantum to use etcd as the backend datastore. ETCDV2Datastore = "etcdv2" // ETCDV3Datastore will tell quantum to use etcd as the backend datastore. ETCDV3Datastore = "etcdv3" // MOCKDatastore will tell quantum to use a moked out backend datastore for testing. MOCKDatastore = "mock" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Datastore ¶
type Datastore interface { // Init should handle setting up the datastore connections, and initializing the mappings/local mapping. Init() error // Mapping should return the mapping and true if it exists, if not the mapping should be nil and false should be returned along with it. Mapping(ip uint32) (*common.Mapping, bool) // GatewayMapping should retun the mapping and true if it exists specifically for destinations outside of the quantum network, if the mapping doesn't exist it will return nil and false. GatewayMapping() (*common.Mapping, bool) // Start should kick off any routines that need to run in the background to groom the mappings and manage the datastore state. Start() // Stop should fully shutdown all operation and ensure that all connections are terminated gracefully. Stop() }
Datastore interface for quantum to use for retrieving mapping data from the backend datastore.
type EtcdV2 ¶
type EtcdV2 struct {
// contains filtered or unexported fields
}
EtcdV2 datastore struct for interacting with the coreos etcd key/value datastore using the v2 api.
func (*EtcdV2) GatewayMapping ¶
GatewayMapping should retun the mapping and true if it exists specifically for destinations outside of the quantum network, if the mapping doesn't exist it will return nil and false.
func (*EtcdV2) Init ¶
Init the Etcd datastore which will open any necessary connections, preform an initial sync of the datastore, and define the local mapping in the datastore.
func (*EtcdV2) Mapping ¶
Mapping returns a mapping and true based on the supplied uint32 representation of an ipv4 address if it exists within the datastore, otherwise it returns nil for the mapping and false.
type EtcdV3 ¶
type EtcdV3 struct {
// contains filtered or unexported fields
}
EtcdV3 datastore struct for interacting with the coreos etcd key/value datastore using the v3 api.
func (*EtcdV3) GatewayMapping ¶
GatewayMapping should retun the mapping and true if it exists specifically for destinations outside of the quantum network, if the mapping doesn't exist it will return nil and false.
func (*EtcdV3) Init ¶
Init the Etcd datastore which will open any necessary connections, preform an initial sync of the datastore, and define the local mapping in the datastore.
func (*EtcdV3) Mapping ¶
Mapping returns a mapping and true based on the supplied uint32 representation of an ipv4 address if it exists within the datastore, otherwise it returns nil for the mapping and false.