firestore

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package firestore is the Cloud Firestore emulation.

gRPC only, like Pub/Sub: the Go client speaks no REST. Two RPCs carry the whole document API — the client routes every write through Commit and every read by reference through BatchGetDocuments, so the per-document RPCs the API documents are never called.

Index

Constants

View Source
const (
	// MaxOpenTransactions is how many may be open at once.
	MaxOpenTransactions = 1000

	// TransactionTTL is how long an untouched handle survives. Real Firestore
	// gives a transaction about a minute before it expires.
	TransactionTTL = time.Minute
)

Transactions are bounded two ways, because a local emulator should fail loudly rather than grow quietly.

Variables

This section is empty.

Functions

This section is empty.

Types

type Service

type Service struct {
	firestorepb.UnimplementedFirestoreServer
	// contains filtered or unexported fields
}

Service holds documents.

func New

func New(kv store.Store, clk clock.Clock) *Service

New wires a service.

func (*Service) BatchGetDocuments

BatchGetDocuments streams the documents a client asked for by reference. DocumentRef.Get and Client.GetAll both arrive here; GetDocument never does.

func (*Service) BatchWrite

BatchWrite applies writes independently: one failing does not stop the rest, and each gets its own status. BulkWriter arrives here rather than at Commit, which is atomic.

func (*Service) BeginTransaction

BeginTransaction opens a transaction and returns its handle.

Isolation here is the commit lock, not multi-version concurrency: a commit applies as a unit and one commit at a time. That is enough to make RunTransaction's read-then-write body behave, and short of real Firestore, which aborts a transaction whose reads were invalidated. A test that depends on seeing that abort will not see it here.

func (*Service) Commit

Commit applies a batch of writes. Every write the Go client makes — Set, Create, Update, Delete, and a WriteBatch — arrives here.

func (*Service) Rollback

func (s *Service) Rollback(ctx context.Context, req *firestorepb.RollbackRequest) (*emptypb.Empty, error)

Rollback discards a transaction. Nothing has been written, so this only forgets the handle.

func (*Service) RunQuery

RunQuery answers a structured query. Every Documents() iterator and every Where() chain the Go client builds arrives here.

Jump to

Keyboard shortcuts

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