Documentation ¶
Index ¶
- Variables
- type MetaDB
- func (m *MetaDB) CreateStore(ctx context.Context, store *store.Store) (*store.Store, error)
- func (m *MetaDB) DeleteBlobRef(ctx context.Context, key uuid.UUID) error
- func (m *MetaDB) DeleteChunkRef(ctx context.Context, blobKey, key uuid.UUID) error
- func (m *MetaDB) DeleteRecord(ctx context.Context, storeKey, key string) error
- func (m *MetaDB) DeleteStore(ctx context.Context, key string) error
- func (m *MetaDB) Disconnect(ctx context.Context) error
- func (m *MetaDB) FindChunkRefByNumber(ctx context.Context, storeKey, recordKey string, number int32) (*chunkref.ChunkRef, error)
- func (m *MetaDB) FindStoreByName(ctx context.Context, name string) (*store.Store, error)
- func (m *MetaDB) GetBlobRef(ctx context.Context, key uuid.UUID) (*blobref.BlobRef, error)
- func (m *MetaDB) GetChildChunkRefs(ctx context.Context, blobKey uuid.UUID) *chunkref.ChunkRefCursor
- func (m *MetaDB) GetCurrentBlobRef(ctx context.Context, storeKey, recordKey string) (*blobref.BlobRef, error)
- func (m *MetaDB) GetRecord(ctx context.Context, storeKey, key string) (*record.Record, error)
- func (m *MetaDB) GetRecords(ctx context.Context, storeKeys, recordKeys []string) ([]*record.Record, error)
- func (m *MetaDB) GetStore(ctx context.Context, key string) (*store.Store, error)
- func (m *MetaDB) InsertBlobRef(ctx context.Context, blob *blobref.BlobRef) (*blobref.BlobRef, error)
- func (m *MetaDB) InsertChunkRef(ctx context.Context, blob *blobref.BlobRef, chunk *chunkref.ChunkRef) error
- func (m *MetaDB) InsertRecord(ctx context.Context, storeKey string, record *record.Record) (*record.Record, error)
- func (m *MetaDB) ListBlobRefsByStatus(ctx context.Context, status blobref.Status) (*blobref.BlobRefCursor, error)
- func (m *MetaDB) ListChunkRefsByStatus(ctx context.Context, status blobref.Status) *chunkref.ChunkRefCursor
- func (m *MetaDB) MarkUncommittedBlobForDeletion(ctx context.Context, key uuid.UUID) error
- func (m *MetaDB) PromoteBlobRefToCurrent(ctx context.Context, blob *blobref.BlobRef) (*record.Record, *blobref.BlobRef, error)
- func (m *MetaDB) PromoteBlobRefWithRecordUpdater(ctx context.Context, blob *blobref.BlobRef, updateTo *record.Record, ...) (*record.Record, *blobref.BlobRef, error)
- func (m *MetaDB) QueryRecords(ctx context.Context, req *pb.QueryRecordsRequest) ([]*record.Record, error)
- func (m *MetaDB) RemoveBlobFromRecord(ctx context.Context, storeKey string, recordKey string) (*record.Record, *blobref.BlobRef, error)
- func (m *MetaDB) UpdateBlobRef(ctx context.Context, blob *blobref.BlobRef) (*blobref.BlobRef, error)
- func (m *MetaDB) UpdateChunkRef(ctx context.Context, chunk *chunkref.ChunkRef) error
- func (m *MetaDB) UpdateRecord(ctx context.Context, storeKey string, key string, updater RecordUpdater) (*record.Record, error)
- func (m *MetaDB) ValidateChunkRefPreconditions(ctx context.Context, chunk *chunkref.ChunkRef) (*blobref.BlobRef, error)
- type RecordUpdater
Constants ¶
This section is empty.
Variables ¶
var (
ErrNoUpdate = errors.New("UpdateRecord doesn't need to commit the change")
)
Functions ¶
This section is empty.
Types ¶
type MetaDB ¶
type MetaDB struct { // Datastore namespace for multi-tenancy Namespace string // contains filtered or unexported fields }
MetaDB is a metadata database manager of Open Saves. The methods return gRPC error codes. Here are some common error codes returned. For additional details, please look at the method help. Common errors:
- NotFound: entity or object is not found
- Aborted: transaction is aborted
- InvalidArgument: key or value provided is not valid
- Internal: internal unrecoverable error
func (*MetaDB) CreateStore ¶
CreateStore creates a new store.
func (*MetaDB) DeleteBlobRef ¶
DeleteBlobRef deletes the BlobRef object from the database. Returned errors:
- NotFound: the blobref object is not found
- FailedPrecondition: the blobref status is Ready and can't be deleted
func (*MetaDB) DeleteChunkRef ¶
DeleteChunkRef deletes the ChunkRef object from the database. Returned errors:
- NotFound: the chunkref object is not found.
- FailedPrecondition: the chunkref status is Ready and can't be deleted.
func (*MetaDB) DeleteRecord ¶
DeleteRecord deletes a record with key in store storeKey. It doesn't return error even if the key is not found in the database.
func (*MetaDB) DeleteStore ¶
DeleteStore deletes the store with specified key. Returns error if the store has any child records.
func (*MetaDB) Disconnect ¶
Disconnect terminates the database connection. Make sure to call this method to release resources (e.g. using defer). The MetaDB instance will not be available after Disconnect().
func (*MetaDB) FindChunkRefByNumber ¶
func (m *MetaDB) FindChunkRefByNumber(ctx context.Context, storeKey, recordKey string, number int32) (*chunkref.ChunkRef, error)
FindChunkRefByNumber returns a ChunkRef object for the specified store, record, and number. The ChunkRef must be Ready and the chunk upload session must be committed.
func (*MetaDB) FindStoreByName ¶
FindStoreByName finds and fetch a store based on the name (complete match).
func (*MetaDB) GetBlobRef ¶
GetBlobRef returns a BlobRef object specified by the key. Returns errors:
- NotFound: the object is not found.
func (*MetaDB) GetChildChunkRefs ¶
GetChildChunkRefs returns a ChunkRef cursor that iterats over child ChunkRef entries of the BlobRef specified by blobkey.
func (*MetaDB) GetCurrentBlobRef ¶
func (m *MetaDB) GetCurrentBlobRef(ctx context.Context, storeKey, recordKey string) (*blobref.BlobRef, error)
GetCurrentBlobRef gets a BlobRef object associated with a record. Returned errors:
- NotFound: the record is not found.
- FailedPrecondition: the record doesn't have a blob.
func (*MetaDB) GetRecord ¶
GetRecord fetches and returns a record with key in store storeKey. Returns error if not found.
func (*MetaDB) GetRecords ¶
func (m *MetaDB) GetRecords(ctx context.Context, storeKeys, recordKeys []string) ([]*record.Record, error)
GetRecords returns records by using the get multi request interface from datastore.
func (*MetaDB) GetStore ¶
GetStore fetches a store based on the key provided. Returns error if the key is not found.
func (*MetaDB) InsertBlobRef ¶
func (m *MetaDB) InsertBlobRef(ctx context.Context, blob *blobref.BlobRef) (*blobref.BlobRef, error)
InsertBlobRef inserts a new BlobRef object to the datastore.
func (*MetaDB) InsertChunkRef ¶
func (m *MetaDB) InsertChunkRef(ctx context.Context, blob *blobref.BlobRef, chunk *chunkref.ChunkRef) error
InsertChunkRef inserts a new ChunkRef object to the datastore. If the current session has another chunk with the same Number, it will be marked for deletion.
func (*MetaDB) InsertRecord ¶
func (m *MetaDB) InsertRecord(ctx context.Context, storeKey string, record *record.Record) (*record.Record, error)
InsertRecord creates a new Record in the store specified with storeKey. Returns error if there is already a record with the same key.
func (*MetaDB) ListBlobRefsByStatus ¶
func (m *MetaDB) ListBlobRefsByStatus(ctx context.Context, status blobref.Status) (*blobref.BlobRefCursor, error)
ListBlobRefsByStatus returns a cursor that iterates over BlobRefs where Status = status.
func (*MetaDB) ListChunkRefsByStatus ¶
func (m *MetaDB) ListChunkRefsByStatus(ctx context.Context, status blobref.Status) *chunkref.ChunkRefCursor
ListChunkRefsByStatus returns a cursor that iterates over ChunkRefs where Status = status.
func (*MetaDB) MarkUncommittedBlobForDeletion ¶
MarkUncommittedBlobForDeletion marks the BlobRef specified by key for deletion if the current status is StatusInitializing. Returns FailedPrecondition is Status is not StatusInitializing.
func (*MetaDB) PromoteBlobRefToCurrent ¶
func (m *MetaDB) PromoteBlobRefToCurrent(ctx context.Context, blob *blobref.BlobRef) (*record.Record, *blobref.BlobRef, error)
PromoteBlobRefToCurrent promotes the provided BlobRef object as a current external blob reference. Returned errors:
- NotFound: the specified record or the blobref was not found
- Internal: BlobRef status transition error
func (*MetaDB) PromoteBlobRefWithRecordUpdater ¶
func (m *MetaDB) PromoteBlobRefWithRecordUpdater(ctx context.Context, blob *blobref.BlobRef, updateTo *record.Record, updater RecordUpdater) (*record.Record, *blobref.BlobRef, error)
PromoteBlobRefWithRecordUpdater promotes the provided BlobRef object as a current external blob reference and updates a record in one transaction. Returned errors:
- NotFound: the specified record or the blobref was not found
- Internal: BlobRef status transition error
func (*MetaDB) QueryRecords ¶
func (m *MetaDB) QueryRecords(ctx context.Context, req *pb.QueryRecordsRequest) ([]*record.Record, error)
QueryRecords returns a list of records that match the given filters.
func (*MetaDB) RemoveBlobFromRecord ¶
func (m *MetaDB) RemoveBlobFromRecord(ctx context.Context, storeKey string, recordKey string) (*record.Record, *blobref.BlobRef, error)
RemoveBlobFromRecord removes the ExternalBlob from the record specified by storeKey and recordKey. It also changes the status of the blob object to BlobRefStatusPendingDeletion. Returned errors:
- NotFound: the specified record or the blobref was not found
- FailedPrecondition: the record doesn't have an external blob
- Internal: BlobRef status transition error
func (*MetaDB) UpdateBlobRef ¶
func (m *MetaDB) UpdateBlobRef(ctx context.Context, blob *blobref.BlobRef) (*blobref.BlobRef, error)
UpdateBlobRef updates a BlobRef object with the new property values. Returns a NotFound error if the key is not found.
func (*MetaDB) UpdateChunkRef ¶
UpdateChunkRef updates a ChunkRef object with the new property values. Returns a NotFound error if the key is not found.
func (*MetaDB) UpdateRecord ¶
func (m *MetaDB) UpdateRecord(ctx context.Context, storeKey string, key string, updater RecordUpdater) (*record.Record, error)
UpdateRecord updates the record in the store specified with storeKey. Pass a callback function to updater and change values there. The callback will be protected by a transaction. Returns error if the store doesn't have a record with the key provided.