Documentation ¶
Index ¶
- Constants
- func BatchDelete(ctx context.Context, es []proto.Message, nf NewFunc) error
- func BatchGet(ctx context.Context, es []proto.Message, nf NewFunc, getID GetIDFunc) ([]proto.Message, error)
- func Delete(ctx context.Context, pm proto.Message, nf NewFunc) error
- func Exists(ctx context.Context, entities []FleetEntity) ([]bool, error)
- func Get(ctx context.Context, pm proto.Message, nf NewFunc) (proto.Message, error)
- func GetOSIndex(osversion string) []string
- func GetServoID(servoHostname string, servoPort int32) string
- func ListQuery(ctx context.Context, entityKind string, pageSize int32, pageToken string, ...) (q *datastore.Query, err error)
- func Put(ctx context.Context, pm proto.Message, nf NewFunc, update bool) (proto.Message, error)
- func PutAll(ctx context.Context, pms []proto.Message, nf NewFunc, update bool) ([]proto.Message, error)
- func PutSingle(ctx context.Context, pm proto.Message, nf NewFunc) (proto.Message, error)
- type FleetEntity
- type GetIDFunc
- type NewFunc
- type OpResult
- type OpResults
- type QueryAllFunc
Constants ¶
const ( InvalidPageToken string = "Invalid Page Token." AlreadyExists string = "Entity already exists." NotFound string = "Entity not found" InternalError string = "Internal Server Error." CannotDelete string = "cannot be deleted" InvalidArgument string = "Invalid argument" PermissionDenied string = "PermissionDenied" )
Error messages for datastore operations
Variables ¶
This section is empty.
Functions ¶
func BatchDelete ¶
BatchDelete removes the entities from the datastore
This is a non-atomic operation Returns error even if partial delete succeeds. Must be used within a Transaction so that partial deletes are rolled back. Using it in a Transaction will rollback the partial deletes and propagate correct error message.
func BatchGet ¶
func BatchGet(ctx context.Context, es []proto.Message, nf NewFunc, getID GetIDFunc) ([]proto.Message, error)
BatchGet returns all entities in table for given IDs.
func Exists ¶
func Exists(ctx context.Context, entities []FleetEntity) ([]bool, error)
Exists checks if a list of fleet entities exist in datastore.
func GetOSIndex ¶
GetOSIndex returns a slics of strings for a given string
func GetServoID ¶
GetServoID returns the servo_id for searching
func ListQuery ¶
func ListQuery(ctx context.Context, entityKind string, pageSize int32, pageToken string, filterMap map[string][]interface{}, keysOnly bool) (q *datastore.Query, err error)
ListQuery constructs a query to list entities with pagination
func PutAll ¶
func PutAll(ctx context.Context, pms []proto.Message, nf NewFunc, update bool) ([]proto.Message, error)
PutAll Upserts entities in the datastore. This is a non-atomic operation and doesnt check if the object already exists before insert/update. Returns error even if partial insert/updates succeeds. Must be used within a Transaction where objects are checked for existence before update/insert. Using it in a Transaction will rollback the partial insert/updates and propagate correct error message.
Types ¶
type FleetEntity ¶
FleetEntity represents the interface of entity in datastore.
type OpResult ¶
type OpResult struct { // Operations: // Get: record the retrieved proto object. // Add: record the proto object to be added. // Delete: record the proto object to be deleted. // Update: record the proto object to be updated. Data proto.Message Err error }
OpResult records the result of datastore operations
type OpResults ¶
type OpResults []*OpResult
OpResults is a list of OpResult.
func GetAll ¶
func GetAll(ctx context.Context, qf QueryAllFunc) (*OpResults, error)
GetAll returns all entities in table.
func Insert ¶
func Insert(ctx context.Context, es []proto.Message, nf NewFunc, update, upsert bool) (*OpResults, error)
Insert inserts the fleet objects.
type QueryAllFunc ¶
type QueryAllFunc func(context.Context) ([]FleetEntity, error)
QueryAllFunc queries all entities for a given table.