Documentation ¶
Index ¶
- type Connector
- func (c *Connector) CheckSchema(ctx context.Context, scope, namePrefix string, ed []*dosa.EntityDefinition) (int32, error)
- func (c *Connector) CreateIfNotExists(_ context.Context, ei *dosa.EntityInfo, values map[string]dosa.FieldValue) error
- func (c *Connector) Range(_ context.Context, ei *dosa.EntityInfo, ...) ([]map[string]dosa.FieldValue, string, error)
- func (c *Connector) Read(_ context.Context, ei *dosa.EntityInfo, values map[string]dosa.FieldValue, ...) (map[string]dosa.FieldValue, error)
- func (c *Connector) Remove(_ context.Context, ei *dosa.EntityInfo, values map[string]dosa.FieldValue) error
- func (c *Connector) RemoveRange(_ context.Context, ei *dosa.EntityInfo, ...) error
- func (c *Connector) Scan(_ context.Context, ei *dosa.EntityInfo, minimumFields []string, token string, ...) ([]map[string]dosa.FieldValue, string, error)
- func (c *Connector) Shutdown() error
- func (c *Connector) Upsert(_ context.Context, ei *dosa.EntityInfo, values map[string]dosa.FieldValue) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Connector ¶
Connector is an in-memory connector. The in-memory connector stores its data like this: map[string]map[string][]map[string]dosa.FieldValue
the first 'string' is the table name (entity name) the second 'string' is the partition key, encoded using encoding/gob to guarantee uniqueness within each 'partition' you have a list of rows ([]map[string]dosa.FieldValue) these rows are kept ordered so that reads are lightning fast and searches are quick too the row itself is a map of field name to value (map[string]dosaFieldValue])
A read-write mutex lock is used to control concurrency, making reads work in parallel but writes are not. There is no attempt to improve the concurrency of the read or write path by adding more granular locks.
func (*Connector) CheckSchema ¶
func (c *Connector) CheckSchema(ctx context.Context, scope, namePrefix string, ed []*dosa.EntityDefinition) (int32, error)
CheckSchema is just a stub; there is no schema management for the in memory connector since creating a new one leaves you with no data!
func (*Connector) CreateIfNotExists ¶
func (c *Connector) CreateIfNotExists(_ context.Context, ei *dosa.EntityInfo, values map[string]dosa.FieldValue) error
CreateIfNotExists inserts a row if it isn't already there. The basic flow is: Find the partition, if it's not there, then create it and insert the row there If the partition is there, and there's data in it, and there's no clustering key, then fail Otherwise, search the partition for the exact same clustering keys. If there, fail if not, then insert it at the right spot (sort.Search does most of the heavy lifting here)
func (*Connector) Range ¶
func (c *Connector) Range(_ context.Context, ei *dosa.EntityInfo, columnConditions map[string][]*dosa.Condition, minimumFields []string, token string, limit int) ([]map[string]dosa.FieldValue, string, error)
Range returns a slice of data from the datastore
func (*Connector) Read ¶
func (c *Connector) Read(_ context.Context, ei *dosa.EntityInfo, values map[string]dosa.FieldValue, minimumFields []string) (map[string]dosa.FieldValue, error)
Read searches for a row. First, it finds the partition, then it searches in the partition for the data, and returns it when it finds it. Again, sort.Search does most of the heavy lifting within a partition
func (*Connector) Remove ¶
func (c *Connector) Remove(_ context.Context, ei *dosa.EntityInfo, values map[string]dosa.FieldValue) error
Remove deletes a single row There's no way to return an error from this method
func (*Connector) RemoveRange ¶
func (c *Connector) RemoveRange(_ context.Context, ei *dosa.EntityInfo, columnConditions map[string][]*dosa.Condition) error
RemoveRange removes all of the elements in the range specified by the entity info and the column conditions.