Documentation
¶
Overview ¶
Package memstore keeps a server's tickets (Store) and attachments (Files) in memory: for tests, and for trying the framework out. Everything is lost when the process ends. It reads back what it is given as the PostgreSQL store does, the times too: to the microsecond, what is finer cut off, and in UTC (us), so that what is tried on it orders and leases as it would on PostgreSQL.
Index ¶
- type Files
- func (f *Files) Delete(_ context.Context, id string) error
- func (f *Files) Has(id string) bool
- func (f *Files) Len() int
- func (f *Files) Open(_ context.Context, id string) (io.ReadCloser, server.FileInfo, error)
- func (f *Files) Put(_ context.Context, info server.FileInfo, r io.Reader) (string, error)
- func (f *Files) Stat(_ context.Context, id string) (server.FileInfo, error)
- func (f *Files) URL(_ context.Context, id string) (string, error)
- type Store
- func (s *Store) Begin(_ context.Context, b server.Begun) (server.Begun, error)
- func (s *Store) BundleArchive(_ context.Context, digest string) ([]byte, error)
- func (s *Store) Bundles(_ context.Context) ([]server.Bundle, error)
- func (s *Store) CountMine(_ context.Context, person string) (map[string]server.MineCount, error)
- func (s *Store) CountTickets(_ context.Context, versions []server.KindVersion) ([]server.TicketCount, error)
- func (s *Store) CountWaiting(_ context.Context, person string) (map[string]int, error)
- func (s *Store) DoneToDo(_ context.Context, id string, at time.Time) error
- func (s *Store) Draft(_ context.Context, person, id string) (server.Draft, error)
- func (s *Store) DueTimers(_ context.Context, now time.Time, lease time.Duration, limit int) ([]server.Timer, error)
- func (s *Store) DueToDo(_ context.Context, now time.Time, lease time.Duration, limit int) ([]server.ToDo, error)
- func (s *Store) ForgetDrafts(_ context.Context, before time.Time, limit int) (int, error)
- func (s *Store) ForgetOperations(_ context.Context, before time.Time, limit int) (int, error)
- func (s *Store) Imports(_ context.Context, since time.Time) ([]time.Time, error)
- func (s *Store) KeepDraft(_ context.Context, d server.Draft, max int) error
- func (s *Store) KeepOutcome(_ context.Context, id string, at time.Time, outcome json.RawMessage) error
- func (s *Store) KeepToDo(_ context.Context, td server.ToDo) error
- func (s *Store) KeepUpload(_ context.Context, u server.Upload, max int) (string, error)
- func (s *Store) KeptVersions(context.Context) ([]server.TicketCount, error)
- func (s *Store) LastImport(context.Context) (server.Record, error)
- func (s *Store) LatestOrganization(_ context.Context) (server.OrgSnapshot, error)
- func (s *Store) LetGoUploads(_ context.Context, before time.Time, limit int) ([]server.Upload, error)
- func (s *Store) Lock(ctx context.Context, ticket string) (context.Context, func(), error)
- func (s *Store) Mine(_ context.Context, person string, q server.MineQuery) ([]server.TicketRecord, error)
- func (s *Store) Moves(_ context.Context, ticket string) ([]server.MoveRecord, error)
- func (s *Store) OpenUploads(_ context.Context, person string) (int, error)
- func (s *Store) Operation(_ context.Context, person, key string) (server.OperationRecord, error)
- func (s *Store) Organization(_ context.Context, id string) (server.OrgSnapshot, error)
- func (s *Store) PutOffTimer(_ context.Context, k server.TimerKey, try time.Time) error
- func (s *Store) Record(_ context.Context, id string) (server.Record, error)
- func (s *Store) Records(_ context.Context, q server.RecordQuery) ([]server.Line, error)
- func (s *Store) Renew(_ context.Context, b server.Begun) error
- func (s *Store) RetryToDo(_ context.Context, id string, try time.Time, why string) error
- func (s *Store) Save(ctx context.Context, m *server.Move) error
- func (s *Store) SaveChange(_ context.Context, c *server.Change) error
- func (s *Store) SaveOrganization(_ context.Context, o server.OrgSnapshot) error
- func (s *Store) Starts(context.Context) ([]server.Start, error)
- func (s *Store) Ticket(_ context.Context, id string) (server.TicketRecord, error)
- func (s *Store) Tickets(_ context.Context, q server.TicketsQuery) ([]server.TicketRecord, error)
- func (s *Store) Timers(_ context.Context, ticket string) ([]server.Timer, error)
- func (s *Store) ToDoItem(_ context.Context, id string) (server.ToDo, error)
- func (s *Store) ToDoList(_ context.Context, ticket string) ([]server.ToDo, error)
- func (s *Store) Trial(context.Context) (any, func(), error)
- func (s *Store) UploadOf(_ context.Context, person, key string) (string, error)
- func (s *Store) UploadsDeleted(_ context.Context, ids []string) error
- func (s *Store) Waiting(_ context.Context, people []string, q server.WaitingQuery) ([]server.TicketRecord, error)
- type Tx
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Files ¶
type Files struct {
Base string
// contains filtered or unexported fields
}
Files is a server.Files in memory: the attachments of a server that keeps its tickets in memory. With a Base, URL answers Base/<id> (as a store that serves its own bytes would); without one, "" (the server sends them). Everything is lost when the process ends.
func (*Files) Put ¶
Put keeps a file and answers its ID: 32 hexadecimal digits. A file with no time (FileInfo.At) is kept with the time it is put, as the other Files keep it; the time is kept to the microsecond, as PostgreSQL keeps it (us).
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is a store in memory. Its zero value is not ready; use New.
func (*Store) Begin ¶
Begin keeps an operation the first time its key is given, and answers what is kept.
func (*Store) BundleArchive ¶
BundleArchive reads a bundle's archive, or ErrNotFound.
func (*Store) Bundles ¶
Bundles reads every bundle the store keeps, without their archives, in the order they were kept.
func (*Store) CountTickets ¶
func (s *Store) CountTickets(_ context.Context, versions []server.KindVersion) ([]server.TicketCount, error)
CountTickets counts the tickets of the versions given by kind, version and status.
func (*Store) CountWaiting ¶
CountWaiting counts the tickets that wait for the person, by kind.
func (*Store) DueTimers ¶
func (s *Store) DueTimers(_ context.Context, now time.Time, lease time.Duration, limit int) ([]server.Timer, error)
DueTimers leases the timers that are due.
func (*Store) DueToDo ¶
func (s *Store) DueToDo(_ context.Context, now time.Time, lease time.Duration, limit int) ([]server.ToDo, error)
DueToDo leases the things to do that are due.
func (*Store) ForgetDrafts ¶
ForgetDrafts forgets up to limit drafts kept before `before`, the oldest first.
func (*Store) ForgetOperations ¶
ForgetOperations forgets up to limit operations answered before `before` and up to limit operations begun before it whose reply was never kept, the oldest first of each, and answers how many of both. Of one time, it forgets them by person, then by key, as Go compares strings (Store.ForgetOperations).
func (*Store) Imports ¶
Imports answers the times of the imports that added a snapshot at or after since.
func (*Store) KeepOutcome ¶
func (s *Store) KeepOutcome(_ context.Context, id string, at time.Time, outcome json.RawMessage) error
KeepOutcome keeps what the work of one said became of it, in place of what it said before.
func (*Store) KeepToDo ¶
KeepToDo keeps a thing to do that no move holds; one with the same ID is left as it is.
func (*Store) KeepUpload ¶
KeepUpload records an upload, unless the person has one with its key, or max uploads no ticket holds.
func (*Store) KeptVersions ¶
KeptVersions counts the tickets of every version the store keeps any of, by kind, version and status.
func (*Store) LastImport ¶
LastImport reads the latest record of an import from the source.
func (*Store) LatestOrganization ¶
LatestOrganization reads the latest snapshot.
func (*Store) LetGoUploads ¶
func (s *Store) LetGoUploads(_ context.Context, before time.Time, limit int) ([]server.Upload, error)
LetGoUploads lets go of the oldest uploads made before `before` that no ticket holds, and answers them after the ones let go earlier whose files are not deleted yet.
func (*Store) Mine ¶
func (s *Store) Mine(_ context.Context, person string, q server.MineQuery) ([]server.TicketRecord, error)
Mine reads a person's own tickets, the newest first.
func (*Store) OpenUploads ¶
OpenUploads counts a person's uploads that no ticket holds and that are not let go.
func (*Store) Organization ¶
Organization reads a snapshot.
func (*Store) PutOffTimer ¶
PutOffTimer keeps a timer to be tried again later.
func (*Store) SaveChange ¶
SaveChange writes a change an administrator made, all or nothing (server.Change).
func (*Store) SaveOrganization ¶
SaveOrganization keeps a snapshot and makes it the latest. A snapshot kept before (the same data) is given the new time.
func (*Store) Tickets ¶
func (s *Store) Tickets(_ context.Context, q server.TicketsQuery) ([]server.TicketRecord, error)
Tickets reads the tickets of some versions of a kind, the newest first: by when they were made (the time of their first move), then by ID.
func (*Store) Trial ¶
Trial answers a transaction that is never committed: what the books register with its AfterCommit is never done.
func (*Store) UploadsDeleted ¶
UploadsDeleted records that the files of uploads let go are deleted.
type Tx ¶
type Tx struct {
// contains filtered or unexported fields
}
Tx is what a move's Books is given: the books in memory register what they do with AfterCommit, and it is done only when the move is saved.
func (*Tx) AfterCommit ¶
func (t *Tx) AfterCommit(f func())
AfterCommit registers f to be done once the move is saved.