Documentation
¶
Index ¶
- Constants
- Variables
- type BatchGetResult
- type ConfigProvider
- type Handler
- func (h *Handler) API() firestorepb.FirestoreServer
- 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(_ context.Context)
- func (h *Handler) Snapshot(ctx context.Context) []byte
- func (h *Handler) StartWorker(ctx context.Context) error
- type InMemoryBackend
- func (b *InMemoryBackend) BatchGetDocuments(req *firestorepb.BatchGetDocumentsRequest) ([]BatchGetResult, []byte, *timestamppb.Timestamp, error)
- func (b *InMemoryBackend) BatchWrite(req *firestorepb.BatchWriteRequest) (*firestorepb.BatchWriteResponse, error)
- func (b *InMemoryBackend) BeginTransaction(req *firestorepb.BeginTransactionRequest) ([]byte, error)
- func (b *InMemoryBackend) Commit(req *firestorepb.CommitRequest) (*firestorepb.CommitResponse, error)
- func (b *InMemoryBackend) CreateDocument(req *firestorepb.CreateDocumentRequest) (*firestorepb.Document, error)
- func (b *InMemoryBackend) DeleteDocument(req *firestorepb.DeleteDocumentRequest) error
- func (b *InMemoryBackend) GetDocument(req *firestorepb.GetDocumentRequest) (*firestorepb.Document, error)
- func (b *InMemoryBackend) ListCollectionIDs(req *firestorepb.ListCollectionIdsRequest) ([]string, string, error)
- func (b *InMemoryBackend) ListDocuments(req *firestorepb.ListDocumentsRequest) ([]*firestorepb.Document, string, error)
- func (b *InMemoryBackend) PartitionQuery(req *firestorepb.PartitionQueryRequest) ([]*firestorepb.Cursor, string, error)
- func (b *InMemoryBackend) Reset()
- func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error
- func (b *InMemoryBackend) Rollback(req *firestorepb.RollbackRequest) error
- func (b *InMemoryBackend) SetClock(now func() time.Time)
- func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte
- func (b *InMemoryBackend) Subscribe() (<-chan struct{}, func())
- func (b *InMemoryBackend) UpdateDocument(req *firestorepb.UpdateDocumentRequest) (*firestorepb.Document, error)
- type Provider
- type Settings
Constants ¶
const DefaultPort = 8080
DefaultPort is the dedicated gRPC listener's default TCP port (the standard Firestore emulator port).
Variables ¶
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 ¶
func (h *Handler) API() firestorepb.FirestoreServer
API exposes the Firestore service for in-process callers (dashboard proxy).
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 gRPC on the dedicated port.
func (*Handler) MatchPriority ¶
MatchPriority is irrelevant because RouteMatcher never matches.
func (*Handler) RouteMatcher ¶
RouteMatcher never matches: Firestore runs on its own gRPC listener.
func (*Handler) Shutdown ¶
Shutdown stops the gRPC server immediately: Listen streams are long-lived, so a graceful drain would stall.
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 ¶
func (b *InMemoryBackend) BatchGetDocuments( req *firestorepb.BatchGetDocumentsRequest, ) ([]BatchGetResult, []byte, *timestamppb.Timestamp, error)
BatchGetDocuments reads documents by name at one snapshot.
func (*InMemoryBackend) BatchWrite ¶
func (b *InMemoryBackend) BatchWrite(req *firestorepb.BatchWriteRequest) (*firestorepb.BatchWriteResponse, error)
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 ¶
func (b *InMemoryBackend) Commit(req *firestorepb.CommitRequest) (*firestorepb.CommitResponse, error)
Commit applies writes atomically, optionally inside a transaction.
func (*InMemoryBackend) CreateDocument ¶
func (b *InMemoryBackend) CreateDocument(req *firestorepb.CreateDocumentRequest) (*firestorepb.Document, error)
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 ¶
func (b *InMemoryBackend) GetDocument(req *firestorepb.GetDocumentRequest) (*firestorepb.Document, error)
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 ¶
func (b *InMemoryBackend) ListDocuments( req *firestorepb.ListDocumentsRequest, ) ([]*firestorepb.Document, string, error)
ListDocuments lists the documents of one collection.
func (*InMemoryBackend) PartitionQuery ¶
func (b *InMemoryBackend) PartitionQuery( req *firestorepb.PartitionQueryRequest, ) ([]*firestorepb.Cursor, string, error)
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 ¶
func (b *InMemoryBackend) Rollback(req *firestorepb.RollbackRequest) error
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 ¶
func (b *InMemoryBackend) UpdateDocument(req *firestorepb.UpdateDocumentRequest) (*firestorepb.Document, error)
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 ¶
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
/* 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.