Documentation
¶
Index ¶
- Constants
- Variables
- type ConfigProvider
- type Handler
- func (h *Handler) Addr() string
- func (h *Handler) ExtractOperation(*echo.Context) string
- func (h *Handler) ExtractResource(*echo.Context) string
- func (h *Handler) GetSupportedOperations() []string
- func (h *Handler) Handler() echo.HandlerFunc
- func (h *Handler) MatchPriority() int
- func (h *Handler) Name() string
- func (h *Handler) Reset()
- func (h *Handler) Restore(ctx context.Context, data []byte) error
- func (h *Handler) RouteMatcher() service.Matcher
- func (h *Handler) Shutdown(ctx context.Context)
- func (h *Handler) Snapshot(ctx context.Context) []byte
- func (h *Handler) StartWorker(ctx context.Context) error
- type InMemoryBackend
- func (b *InMemoryBackend) AllocateIDs(in *datastorepb.AllocateIdsRequest) (*datastorepb.AllocateIdsResponse, error)
- func (b *InMemoryBackend) BeginTransaction(in *datastorepb.BeginTransactionRequest) (*datastorepb.BeginTransactionResponse, error)
- func (b *InMemoryBackend) Commit(in *datastorepb.CommitRequest) (*datastorepb.CommitResponse, error)
- func (b *InMemoryBackend) CreateIndex(in *adminpb.CreateIndexRequest) (*longrunningpb.Operation, error)
- func (b *InMemoryBackend) DeleteIndex(in *adminpb.DeleteIndexRequest) (*longrunningpb.Operation, error)
- func (b *InMemoryBackend) GetIndex(in *adminpb.GetIndexRequest) (*adminpb.Index, error)
- func (b *InMemoryBackend) ListIndexes(in *adminpb.ListIndexesRequest) (*adminpb.ListIndexesResponse, error)
- func (b *InMemoryBackend) Lookup(in *datastorepb.LookupRequest) (*datastorepb.LookupResponse, error)
- func (b *InMemoryBackend) ReserveIDs(in *datastorepb.ReserveIdsRequest) (*datastorepb.ReserveIdsResponse, error)
- func (b *InMemoryBackend) Reset()
- func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error
- func (b *InMemoryBackend) Rollback(in *datastorepb.RollbackRequest) (*datastorepb.RollbackResponse, error)
- func (b *InMemoryBackend) RunAggregationQuery(in *datastorepb.RunAggregationQueryRequest) (*datastorepb.RunAggregationQueryResponse, error)
- func (b *InMemoryBackend) RunQuery(in *datastorepb.RunQueryRequest) (*datastorepb.RunQueryResponse, error)
- func (b *InMemoryBackend) SetClock(now func() time.Time)
- func (b *InMemoryBackend) SetEnforceIndexes(on bool)
- func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte
- type Provider
- type Settings
Constants ¶
const DefaultPort = 8143
DefaultPort is the dedicated gRPC and REST listener's default TCP port (DATASTORE_EMULATOR_HOST).
Variables ¶
var ErrNilAppContext = errors.New("gcpdatastore: nil app context")
ErrNilAppContext is returned when Init is called with a nil AppContext.
Functions ¶
This section is empty.
Types ¶
type ConfigProvider ¶
type ConfigProvider interface {
GetGCPDatastoreSettings() Settings
}
ConfigProvider extracts Datastore configuration from the AppContext Config.
type Handler ¶
type Handler struct {
Backend *InMemoryBackend
Port int
// contains filtered or unexported fields
}
Handler serves the Datastore API on a dedicated gRPC and REST listener.
func NewHandler ¶
func NewHandler(backend *InMemoryBackend) *Handler
NewHandler creates a Handler; callers override Port from Settings.
func (*Handler) ExtractOperation ¶
ExtractOperation is unused: requests never reach the shared router.
func (*Handler) ExtractResource ¶
ExtractResource is unused: requests never reach the shared router.
func (*Handler) GetSupportedOperations ¶
GetSupportedOperations lists the supported gRPC methods.
func (*Handler) Handler ¶
func (h *Handler) Handler() echo.HandlerFunc
Handler returns a 404 handler; the real API is on the dedicated port.
func (*Handler) MatchPriority ¶
MatchPriority is irrelevant because RouteMatcher never matches.
func (*Handler) RouteMatcher ¶
RouteMatcher never matches: Datastore runs on its own listener.
type InMemoryBackend ¶
type InMemoryBackend struct {
// contains filtered or unexported fields
}
InMemoryBackend holds every entity, transaction, reserved id and index under one lock.
func NewInMemoryBackend ¶
func NewInMemoryBackend() *InMemoryBackend
NewInMemoryBackend creates an empty backend that enforces composite indexes.
func (*InMemoryBackend) AllocateIDs ¶
func (b *InMemoryBackend) AllocateIDs(in *datastorepb.AllocateIdsRequest) (*datastorepb.AllocateIdsResponse, error)
AllocateIDs fills in the ids of incomplete keys.
func (*InMemoryBackend) BeginTransaction ¶
func (b *InMemoryBackend) BeginTransaction( in *datastorepb.BeginTransactionRequest, ) (*datastorepb.BeginTransactionResponse, error)
BeginTransaction starts a read-write or read-only transaction.
func (*InMemoryBackend) Commit ¶
func (b *InMemoryBackend) Commit(in *datastorepb.CommitRequest) (*datastorepb.CommitResponse, error)
Commit applies mutations atomically, optionally inside a transaction.
func (*InMemoryBackend) CreateIndex ¶
func (b *InMemoryBackend) CreateIndex(in *adminpb.CreateIndexRequest) (*longrunningpb.Operation, error)
CreateIndex registers a composite index; it is READY immediately.
func (*InMemoryBackend) DeleteIndex ¶
func (b *InMemoryBackend) DeleteIndex(in *adminpb.DeleteIndexRequest) (*longrunningpb.Operation, error)
DeleteIndex removes a composite index.
func (*InMemoryBackend) GetIndex ¶
func (b *InMemoryBackend) GetIndex(in *adminpb.GetIndexRequest) (*adminpb.Index, error)
GetIndex returns one composite index.
func (*InMemoryBackend) ListIndexes ¶
func (b *InMemoryBackend) ListIndexes(in *adminpb.ListIndexesRequest) (*adminpb.ListIndexesResponse, error)
ListIndexes pages through a project's composite indexes in creation order.
func (*InMemoryBackend) Lookup ¶
func (b *InMemoryBackend) Lookup(in *datastorepb.LookupRequest) (*datastorepb.LookupResponse, error)
Lookup returns the entities for the requested keys, split into found and missing.
func (*InMemoryBackend) ReserveIDs ¶
func (b *InMemoryBackend) ReserveIDs(in *datastorepb.ReserveIdsRequest) (*datastorepb.ReserveIdsResponse, error)
ReserveIDs prevents the numeric ids of the given keys from being auto-allocated.
func (*InMemoryBackend) Reset ¶
func (b *InMemoryBackend) Reset()
Reset clears all entities, transactions, reserved ids, indexes and operations.
func (*InMemoryBackend) Restore ¶
func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error
Restore loads backend state from a snapshot.
func (*InMemoryBackend) Rollback ¶
func (b *InMemoryBackend) Rollback(in *datastorepb.RollbackRequest) (*datastorepb.RollbackResponse, error)
Rollback discards a transaction.
func (*InMemoryBackend) RunAggregationQuery ¶
func (b *InMemoryBackend) RunAggregationQuery( in *datastorepb.RunAggregationQueryRequest, ) (*datastorepb.RunAggregationQueryResponse, error)
RunAggregationQuery computes count, sum and avg over a query.
func (*InMemoryBackend) RunQuery ¶
func (b *InMemoryBackend) RunQuery(in *datastorepb.RunQueryRequest) (*datastorepb.RunQueryResponse, error)
RunQuery executes a structured or GQL query.
func (*InMemoryBackend) SetClock ¶
func (b *InMemoryBackend) SetClock(now func() time.Time)
SetClock replaces the backend clock.
func (*InMemoryBackend) SetEnforceIndexes ¶
func (b *InMemoryBackend) SetEnforceIndexes(on bool)
SetEnforceIndexes toggles FAILED_PRECONDITION for queries that need a missing composite index.
type Provider ¶
type Provider struct{}
Provider implements service.Provider for Google Cloud Datastore. It serves gRPC and REST on its own listener (see Handler.StartWorker) and never matches on the shared AWS router.
func (*Provider) Init ¶
func (p *Provider) Init(ctx *service.AppContext) (service.Registerable, error)
Init creates the backend and handler; the port is bound in StartWorker.
type Settings ¶
type Settings struct {
Port int `` //nolint:lll // config struct tags are intentionally verbose
/* 244-byte string literal not displayed */
EnforceIndexes bool `` //nolint:lll // config struct tags are intentionally verbose
/* 254-byte string literal not displayed */
}
Settings holds service-level configuration, embedded in the root CLI as CLI.GCPDatastore.
func DefaultSettings ¶
func DefaultSettings() Settings
DefaultSettings returns the settings used when no ConfigProvider is available.