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
- type Service
- func (s *Service) BatchGetDocuments(req *firestorepb.BatchGetDocumentsRequest, ...) error
- func (s *Service) BatchWrite(ctx context.Context, req *firestorepb.BatchWriteRequest) (*firestorepb.BatchWriteResponse, error)
- func (s *Service) BeginTransaction(ctx context.Context, req *firestorepb.BeginTransactionRequest) (*firestorepb.BeginTransactionResponse, error)
- func (s *Service) Commit(ctx context.Context, req *firestorepb.CommitRequest) (*firestorepb.CommitResponse, error)
- func (s *Service) Rollback(ctx context.Context, req *firestorepb.RollbackRequest) (*emptypb.Empty, error)
- func (s *Service) RunQuery(req *firestorepb.RunQueryRequest, stream firestorepb.Firestore_RunQueryServer) error
Constants ¶
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 (*Service) BatchGetDocuments ¶
func (s *Service) BatchGetDocuments(req *firestorepb.BatchGetDocumentsRequest, stream firestorepb.Firestore_BatchGetDocumentsServer) error
BatchGetDocuments streams the documents a client asked for by reference. DocumentRef.Get and Client.GetAll both arrive here; GetDocument never does.
func (*Service) BatchWrite ¶
func (s *Service) BatchWrite(ctx context.Context, req *firestorepb.BatchWriteRequest) (*firestorepb.BatchWriteResponse, error)
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 ¶
func (s *Service) BeginTransaction(ctx context.Context, req *firestorepb.BeginTransactionRequest) (*firestorepb.BeginTransactionResponse, error)
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 ¶
func (s *Service) Commit(ctx context.Context, req *firestorepb.CommitRequest) (*firestorepb.CommitResponse, error)
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 ¶
func (s *Service) RunQuery(req *firestorepb.RunQueryRequest, stream firestorepb.Firestore_RunQueryServer) error
RunQuery answers a structured query. Every Documents() iterator and every Where() chain the Go client builds arrives here.