2.2 KiB
2.2 KiB
Storage
Source: storage.go (project storage, top-level), player_storage.go (player storage, handle only).
Types: ProjectStorage, ProjectStorageList, ProjectStorageInput, PlayerStorage.
Top-level client.Storage is project (global) storage. Player storage is reachable only via client.Player(id).Storage().
Project storage (client.Storage)
func (s *StorageService) List(ctx context.Context, parameters ListStorageParameters) (*ProjectStorageList, error)
type ListStorageParameters struct {
Limit int
Cursor string // plain string, not *string
Search string
}
// ProjectStorageList: {Items []ProjectStorage, NextCursor string}
func (s *StorageService) Get(ctx context.Context, itemType string) (*ProjectStorage, error)
func (s *StorageService) Upsert(ctx context.Context, parameters UpsertStorageParameters) error
type UpsertStorageParameters struct {
IdempotencyKey string
Items []ProjectStorageInput
}
// ProjectStorageInput: {Type, Data, ExpiresAt, ReadPermission, WritePermission}
func (s *StorageService) Delete(ctx context.Context, parameters DeleteStorageParameters) error
type DeleteStorageParameters struct {
IdempotencyKey string
Types []string // batch delete by item types
}
ProjectStorage (returned item): {ID, Type, Data, Size int64, Version int64, ReadPermission, WritePermission, ExpiresAt, UpdatedAt}.
Player storage (client.Player(id).Storage())
func (h *PlayerStorageHandle) Get(ctx context.Context, storageType string) (*PlayerStorage, error)
func (h *PlayerStorageHandle) Upsert(ctx context.Context, parameters UpsertPlayerStorageParameters) (*PlayerStorage, error)
type UpsertPlayerStorageParameters struct {
IdempotencyKey string
Type string
Data string
ExpiresAt string
}
func (h *PlayerStorageHandle) Delete(ctx context.Context, parameters DeletePlayerStorageParameters) error
type DeletePlayerStorageParameters struct {
IdempotencyKey string
Type string
}
PlayerStorage: {ID, PlayerID, Type, Data, ExpiresAt, UpdatedAt}.
The handle's Upsert/Delete send single-item batches to PUT/DELETE /players/storage — the same batch rules (idempotency key, all-or-nothing) apply.