Help us shape the future of Go! Take the 2026 Go Developer Survey

gcpdatastore

package
v1.9.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 1, 2026 License: MIT Imports: 38 Imported by: 0

README

Cloud Datastore

Parity grade: B · SDK cloud.google.com/go/datastore@v1.25.0 · last audited 2026-10-26 (70ee58098)

Coverage

Metric Value
PARITY entries audited 13 (10 ok, 3 partial)
Feature families 8 (3 ok, 5 partial)
Known gaps 5
Deferred items 0
Resource leaks clean
Known gaps
  • ExportEntities and ImportEntities are not served (they need a Cloud Storage bucket target); the admin service answers UNIMPLEMENTED for them.
  • Query explain (explain_options), vector search (find_nearest), property metadata queries are not supported; explain and find_nearest return UNIMPLEMENTED, and a property_mask is applied to full entities only.
  • Pessimistic concurrency, point-in-time recovery beyond one hour, multiple named databases' lifecycle API and TTL policies are not modelled; the database_id field only partitions data.
  • Composite index rules cover only the cases the documentation states; the index build is instantaneous (no CREATING state) and the exact wording of FAILED_PRECONDITION and ABORTED messages was chosen without a production reference.
  • There is no dashboard page.

More

Documentation

Index

Constants

View Source
const DefaultPort = 8143

DefaultPort is the dedicated gRPC and REST listener's default TCP port (DATASTORE_EMULATOR_HOST).

Variables

View Source
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) Addr

func (h *Handler) Addr() string

Addr returns the bound listener address, or "" before StartWorker.

func (*Handler) ExtractOperation

func (h *Handler) ExtractOperation(*echo.Context) string

ExtractOperation is unused: requests never reach the shared router.

func (*Handler) ExtractResource

func (h *Handler) ExtractResource(*echo.Context) string

ExtractResource is unused: requests never reach the shared router.

func (*Handler) GetSupportedOperations

func (h *Handler) GetSupportedOperations() []string

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

func (h *Handler) MatchPriority() int

MatchPriority is irrelevant because RouteMatcher never matches.

func (*Handler) Name

func (h *Handler) Name() string

Name returns the service name.

func (*Handler) Reset

func (h *Handler) Reset()

Reset clears all state.

func (*Handler) Restore

func (h *Handler) Restore(ctx context.Context, data []byte) error

Restore implements persistence.Persistable by delegating to the backend.

func (*Handler) RouteMatcher

func (h *Handler) RouteMatcher() service.Matcher

RouteMatcher never matches: Datastore runs on its own listener.

func (*Handler) Shutdown

func (h *Handler) Shutdown(ctx context.Context)

Shutdown stops the listener, forcing a close after a short grace period.

func (*Handler) Snapshot

func (h *Handler) Snapshot(ctx context.Context) []byte

Snapshot implements persistence.Persistable by delegating to the backend.

func (*Handler) StartWorker

func (h *Handler) StartWorker(ctx context.Context) error

StartWorker binds the dedicated listener synchronously so a port conflict is returned to the caller.

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

AllocateIDs fills in the ids of incomplete keys.

func (*InMemoryBackend) BeginTransaction

BeginTransaction starts a read-write or read-only transaction.

func (*InMemoryBackend) Commit

Commit applies mutations atomically, optionally inside a transaction.

func (*InMemoryBackend) CreateIndex

CreateIndex registers a composite index; it is READY immediately.

func (*InMemoryBackend) DeleteIndex

DeleteIndex removes a composite index.

func (*InMemoryBackend) GetIndex

GetIndex returns one composite index.

func (*InMemoryBackend) ListIndexes

ListIndexes pages through a project's composite indexes in creation order.

func (*InMemoryBackend) Lookup

Lookup returns the entities for the requested keys, split into found and missing.

func (*InMemoryBackend) ReserveIDs

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

Rollback discards a transaction.

func (*InMemoryBackend) RunAggregationQuery

RunAggregationQuery computes count, sum and avg over a query.

func (*InMemoryBackend) RunQuery

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.

func (*InMemoryBackend) Snapshot

func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte

Snapshot serialises the current state of every entity, reserved ids, indexes and operations. Version history and open transactions are not persisted.

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

Init creates the backend and handler; the port is bound in StartWorker.

func (*Provider) Name

func (p *Provider) Name() string

Name returns the service provider name.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL