store¶
Index¶
- type CachedStore
- func NewCachedStore(backing DocumentStore, flushInterval time.Duration) *CachedStore
- func (cs *CachedStore) AppendOperation(ctx context.Context, id string, op ot.Operation, version int) error
- func (cs *CachedStore) Close()
- func (cs *CachedStore) Create(ctx context.Context, id, content string) error
- func (cs *CachedStore) Get(ctx context.Context, id string) (*DocumentInfo, error)
- func (cs *CachedStore) GetOperations(ctx context.Context, id string, fromVersion int) ([]ot.Operation, error)
- func (cs *CachedStore) List(ctx context.Context) ([]DocumentInfo, error)
- func (cs *CachedStore) UpdateContent(ctx context.Context, id, content string, version int) error
- type DocumentInfo
- type DocumentStore
- type FirestoreStore
- func NewFirestoreStore(client *firestore.Client) *FirestoreStore
- func (s *FirestoreStore) AppendOperation(ctx context.Context, id string, op ot.Operation, version int) error
- func (s *FirestoreStore) Create(ctx context.Context, id, content string) error
- func (s *FirestoreStore) Get(ctx context.Context, id string) (*DocumentInfo, error)
- func (s *FirestoreStore) GetOperations(ctx context.Context, id string, fromVersion int) ([]ot.Operation, error)
- func (s *FirestoreStore) List(ctx context.Context) ([]DocumentInfo, error)
- func (s *FirestoreStore) UpdateContent(ctx context.Context, id, content string, version int) error
- type MemoryStore
- func NewMemoryStore() *MemoryStore
- func (s *MemoryStore) AppendOperation(_ context.Context, id string, op ot.Operation, version int) error
- func (s *MemoryStore) Create(_ context.Context, id, content string) error
- func (s *MemoryStore) Get(_ context.Context, id string) (*DocumentInfo, error)
- func (s *MemoryStore) GetOperations(_ context.Context, id string, fromVersion int) ([]ot.Operation, error)
- func (s *MemoryStore) List(_ context.Context) ([]DocumentInfo, error)
- func (s *MemoryStore) UpdateContent(_ context.Context, id, content string, version int) error
type CachedStore¶
CachedStore wraps a backing DocumentStore with an in-memory cache. All reads and writes are served from the cache. Dirty documents are flushed to the backing store periodically in the background.
func NewCachedStore¶
NewCachedStore creates a CachedStore that caches in memory and flushes dirty documents to the backing store every flushInterval.
func (*CachedStore) AppendOperation¶
func (cs *CachedStore) AppendOperation(ctx context.Context, id string, op ot.Operation, version int) error
func (*CachedStore) Close¶
Close signals the flush loop to perform a final flush and waits for it to complete.
func (*CachedStore) Create¶
func (*CachedStore) Get¶
func (*CachedStore) GetOperations¶
func (cs *CachedStore) GetOperations(ctx context.Context, id string, fromVersion int) ([]ot.Operation, error)
func (*CachedStore) List¶
func (*CachedStore) UpdateContent¶
type DocumentInfo¶
DocumentInfo holds document metadata and content.
type DocumentInfo struct {
ID string
Content string
Version int
CreatedAt time.Time
UpdatedAt time.Time
}
type DocumentStore¶
DocumentStore abstracts document persistence. Implementations: MemoryStore (in-memory), FirestoreStore (Google Cloud Firestore).
type DocumentStore interface {
Create(ctx context.Context, id, content string) error
Get(ctx context.Context, id string) (*DocumentInfo, error)
List(ctx context.Context) ([]DocumentInfo, error)
UpdateContent(ctx context.Context, id, content string, version int) error
AppendOperation(ctx context.Context, id string, op ot.Operation, version int) error
GetOperations(ctx context.Context, id string, fromVersion int) ([]ot.Operation, error)
}
type FirestoreStore¶
FirestoreStore is a Firestore-backed implementation of DocumentStore.
func NewFirestoreStore¶
NewFirestoreStore creates a new FirestoreStore using the given Firestore client.
func (*FirestoreStore) AppendOperation¶
func (s *FirestoreStore) AppendOperation(ctx context.Context, id string, op ot.Operation, version int) error
func (*FirestoreStore) Create¶
func (*FirestoreStore) Get¶
func (*FirestoreStore) GetOperations¶
func (s *FirestoreStore) GetOperations(ctx context.Context, id string, fromVersion int) ([]ot.Operation, error)
func (*FirestoreStore) List¶
func (*FirestoreStore) UpdateContent¶
type MemoryStore¶
MemoryStore is an in-memory implementation of DocumentStore.
func NewMemoryStore¶
func (*MemoryStore) AppendOperation¶
func (s *MemoryStore) AppendOperation(_ context.Context, id string, op ot.Operation, version int) error
func (*MemoryStore) Create¶
func (*MemoryStore) Get¶
func (*MemoryStore) GetOperations¶
func (s *MemoryStore) GetOperations(_ context.Context, id string, fromVersion int) ([]ot.Operation, error)
func (*MemoryStore) List¶
func (*MemoryStore) UpdateContent¶
Generated by gomarkdoc