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
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 ¶
This section is empty.
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) // 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 Etcd ¶
type Etcd struct {
// contains filtered or unexported fields
}
Etcd datastore struct for interacting with the coreos etcd key/value datastore.
func (*Etcd) 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 (*Etcd) 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 Mock ¶
Mock datastore struct for testing.