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

gcpfirestore

package
v1.8.3 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: MIT Imports: 33 Imported by: 0

README

Google Cloud Firestore

Parity grade: B · SDK cloud.google.com/go/firestore@v1.26.0 · last audited 2026-10-18 (4566bb099)

Coverage

Metric Value
PARITY entries audited 15 (15 ok)
Feature families 5 (3 ok, 2 partial)
Known gaps 4
Deferred items 0
Resource leaks clean
Known gaps
  • The bidirectional Write stream and ExecutePipeline return UNIMPLEMENTED; the official Go client uses Commit and BatchWrite instead.
  • Only the (default)-style database named in the resource path is addressed implicitly; database creation and admin APIs (indexes, exports) are not served.
  • Vector fields, find_nearest, explain options and field-level indexes are not supported; all queries run without index requirements.
  • Listen sends no ExistenceFilter and does not replay missed changes on resume; a resumed target is reset and re-sent in full.

More

Documentation

Index

Constants

View Source
const DefaultPort = 8080

DefaultPort is the dedicated gRPC listener's default TCP port (the standard Firestore emulator port).

Variables

View Source
var ErrNilAppContext = errors.New("gcpfirestore: nil app context")

ErrNilAppContext is returned when Init is called with a nil AppContext.

Functions

This section is empty.

Types

type BatchGetResult

type BatchGetResult struct {
	Found   *firestorepb.Document
	Missing string
}

BatchGetResult is one entry of a BatchGetDocuments stream.

type ConfigProvider

type ConfigProvider interface {
	GetGCPFirestoreSettings() Settings
}

ConfigProvider extracts Firestore configuration from the AppContext Config.

type Handler

type Handler struct {
	Backend *InMemoryBackend

	Port int
	// contains filtered or unexported fields
}

Handler serves the Firestore gRPC API on a dedicated listener.

func NewHandler

func NewHandler(backend *InMemoryBackend) *Handler

NewHandler creates a Handler; callers override Port from Settings.

func (*Handler) API

API exposes the Firestore service for in-process callers (dashboard proxy).

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 gRPC 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 in-memory 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: Firestore runs on its own gRPC listener.

func (*Handler) Shutdown

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

Shutdown stops the gRPC server immediately: Listen streams are long-lived, so a graceful drain would stall.

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 document, transaction and listener under one lock.

func NewInMemoryBackend

func NewInMemoryBackend() *InMemoryBackend

NewInMemoryBackend creates an empty backend.

func (*InMemoryBackend) BatchGetDocuments

BatchGetDocuments reads documents by name at one snapshot.

func (*InMemoryBackend) BatchWrite

BatchWrite applies each write independently and reports a status per write.

func (*InMemoryBackend) BeginTransaction

func (b *InMemoryBackend) BeginTransaction(req *firestorepb.BeginTransactionRequest) ([]byte, error)

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

func (*InMemoryBackend) Commit

Commit applies writes atomically, optionally inside a transaction.

func (*InMemoryBackend) CreateDocument

CreateDocument creates a document, generating an id when none is given.

func (*InMemoryBackend) DeleteDocument

func (b *InMemoryBackend) DeleteDocument(req *firestorepb.DeleteDocumentRequest) error

DeleteDocument deletes a document; deleting an absent document succeeds unless a precondition says otherwise.

func (*InMemoryBackend) GetDocument

GetDocument reads one document.

func (*InMemoryBackend) ListCollectionIDs

func (b *InMemoryBackend) ListCollectionIDs(
	req *firestorepb.ListCollectionIdsRequest,
) ([]string, string, error)

ListCollectionIDs lists the collection ids directly under a document or the database root.

func (*InMemoryBackend) ListDocuments

ListDocuments lists the documents of one collection.

func (*InMemoryBackend) PartitionQuery

PartitionQuery splits a collection-group query into cursors over document names.

func (*InMemoryBackend) Reset

func (b *InMemoryBackend) Reset()

Reset clears all documents and transactions.

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) SetClock

func (b *InMemoryBackend) SetClock(now func() time.Time)

SetClock replaces the backend clock.

func (*InMemoryBackend) Snapshot

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

Snapshot serialises the current state of every document; version history and transactions are not persisted.

func (*InMemoryBackend) Subscribe

func (b *InMemoryBackend) Subscribe() (<-chan struct{}, func())

Subscribe returns a channel signalled after every state change and a cancel function.

func (*InMemoryBackend) UpdateDocument

UpdateDocument writes a document, honouring the update mask and precondition.

type Provider

type Provider struct{}

Provider implements service.Provider for Google Cloud Firestore. It serves gRPC 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
	/* 203-byte string literal not displayed */
}

Settings holds service-level configuration, embedded in the root CLI command as CLI.GCPFirestore.

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