Documentation
¶
Overview ¶
Package memory is an in-process store.Store for unit tests and for `kojo eval --local`. It keeps everything in maps behind one mutex and forgets it on exit: production always runs on Postgres.
Index ¶
- type Store
- func (s *Store) ActivateRevision(_ context.Context, id string) (*store.Revision, error)
- func (s *Store) ActiveRevision(_ context.Context, scope, object string) (*store.Revision, error)
- func (s *Store) ActiveRevisions(_ context.Context, scope string) ([]store.Revision, error)
- func (s *Store) AddMemory(_ context.Context, m *store.Memory) error
- func (s *Store) AddSessionMessage(_ context.Context, m *store.SessionMessage, max int) error
- func (s *Store) AppendAudit(_ context.Context, e store.AuditEntry) error
- func (s *Store) AppendStep(_ context.Context, st *store.Step) error
- func (s *Store) Claim(ctx context.Context, worker string, lease time.Duration) (*store.Session, error)
- func (s *Store) ClaimWithin(_ context.Context, worker string, lease time.Duration, caps store.Caps) (*store.Session, error)
- func (s *Store) Close()
- func (s *Store) CreateCampaign(_ context.Context, c *store.Campaign) error
- func (s *Store) DecideApproval(_ context.Context, id, status, by string) (*store.Approval, error)
- func (s *Store) DeleteDraft(_ context.Context, id string) error
- func (s *Store) DeleteMemory(_ context.Context, id string) error
- func (s *Store) Enqueue(_ context.Context, req store.Request) (*store.Session, error)
- func (s *Store) GetApproval(_ context.Context, id string) (*store.Approval, error)
- func (s *Store) GetCampaign(_ context.Context, id string) (*store.Campaign, error)
- func (s *Store) GetDraft(_ context.Context, id string) (*store.SkillDraft, error)
- func (s *Store) GetEvalRun(_ context.Context, id string) (*store.EvalRun, error)
- func (s *Store) GetMemory(_ context.Context, id string) (*store.Memory, error)
- func (s *Store) GetProposal(_ context.Context, id string) (*store.Proposal, error)
- func (s *Store) GetPullRequest(_ context.Context, repo string, number int) (*store.PullRequest, error)
- func (s *Store) GetRevision(_ context.Context, id string) (*store.Revision, error)
- func (s *Store) GetScheduleState(_ context.Context, key string) (*store.ScheduleState, error)
- func (s *Store) GetSession(_ context.Context, id string) (*store.Session, error)
- func (s *Store) Heartbeat(_ context.Context, sessionID, worker string, lease time.Duration) error
- func (s *Store) ListAudit(_ context.Context, f store.AuditFilter) ([]store.AuditEntry, error)
- func (s *Store) ListCampaigns(_ context.Context, f store.CampaignFilter) ([]store.Campaign, error)
- func (s *Store) ListDrafts(_ context.Context, scope string) ([]store.SkillDraft, error)
- func (s *Store) ListEvalRuns(_ context.Context, skill string, limit int) ([]store.EvalRun, error)
- func (s *Store) ListMemory(_ context.Context, f store.MemoryFilter) ([]store.Memory, error)
- func (s *Store) ListProposals(_ context.Context, f store.ProposalFilter) ([]store.Proposal, error)
- func (s *Store) ListPullRequests(_ context.Context, f store.PullRequestFilter) ([]store.PullRequest, error)
- func (s *Store) ListRevisions(_ context.Context, scope, object string, limit int) ([]store.Revision, error)
- func (s *Store) ListSessionMessages(_ context.Context, sessionID string) ([]store.SessionMessage, error)
- func (s *Store) ListSessions(_ context.Context, f store.SessionFilter) ([]store.Session, error)
- func (s *Store) ListSkillIndex(_ context.Context, repo string) ([]store.SkillIndexEntry, error)
- func (s *Store) ListSteps(_ context.Context, sessionID string) ([]store.Step, error)
- func (s *Store) ListUsers(_ context.Context) ([]store.User, error)
- func (s *Store) MarkSessionMessages(_ context.Context, sessionID string, ids []string, status, to string) ([]store.SessionMessage, error)
- func (s *Store) Ping(context.Context) error
- func (s *Store) PutApproval(_ context.Context, a *store.Approval) error
- func (s *Store) PutDraft(_ context.Context, d *store.SkillDraft) error
- func (s *Store) PutEvalRun(_ context.Context, r *store.EvalRun) error
- func (s *Store) PutProposal(_ context.Context, p *store.Proposal) error
- func (s *Store) PutRevision(_ context.Context, r store.Revision, activate bool) (*store.Revision, error)
- func (s *Store) PutScheduleState(_ context.Context, st store.ScheduleState) error
- func (s *Store) RecordPullRequest(_ context.Context, pr store.PullRequest) error
- func (s *Store) Release(_ context.Context, sessionID, worker string, status store.SessionStatus, ...) error
- func (s *Store) ReplaceSkillIndex(_ context.Context, repo string, entries []store.SkillIndexEntry) error
- func (s *Store) RequestCancel(_ context.Context, id string) error
- func (s *Store) SearchMemory(_ context.Context, q store.MemoryQuery) ([]store.Memory, error)
- func (s *Store) SetClock(now func() time.Time)
- func (s *Store) SpendByPerson(_ context.Context, from, to time.Time) (map[string]float64, error)
- func (s *Store) SpendByRepo(_ context.Context, from, to time.Time) (map[string]float64, error)
- func (s *Store) SpendBySkill(_ context.Context, from, to time.Time) (map[string]float64, error)
- func (s *Store) SpendSince(_ context.Context, t time.Time) (float64, error)
- func (s *Store) TryLead(_ context.Context, name string) (func(), bool, error)
- func (s *Store) TryUpdateCampaign(ctx context.Context, id string, fn func(*store.Campaign) error) (*store.Campaign, error)
- func (s *Store) UndeliveredMessages(_ context.Context, sessionID string) ([]store.SessionMessage, error)
- func (s *Store) UpdateCampaign(ctx context.Context, id string, fn func(*store.Campaign) error) (*store.Campaign, error)
- func (s *Store) UpdatePullRequest(_ context.Context, pr *store.PullRequest) error
- func (s *Store) UpdateSession(_ context.Context, in *store.Session) error
- func (s *Store) UpdateStep(_ context.Context, st *store.Step) error
- func (s *Store) UpsertUser(_ context.Context, u store.User) error
- func (s *Store) WatchConfig(ctx context.Context) (<-chan store.ConfigChange, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is the in-memory store. The zero value is not usable: call New.
func (*Store) ActivateRevision ¶
ActivateRevision implements store.Store.
func (*Store) ActiveRevision ¶
ActiveRevision implements store.Store.
func (*Store) ActiveRevisions ¶
ActiveRevisions implements store.Store.
func (*Store) AddSessionMessage ¶
AddSessionMessage implements store.Store.
func (*Store) AppendAudit ¶
AppendAudit implements store.Store.
func (*Store) AppendStep ¶
AppendStep implements store.Store.
func (*Store) Claim ¶
func (s *Store) Claim(ctx context.Context, worker string, lease time.Duration) (*store.Session, error)
Claim implements store.Store.
func (*Store) ClaimWithin ¶ added in v0.3.0
func (s *Store) ClaimWithin(_ context.Context, worker string, lease time.Duration, caps store.Caps) (*store.Session, error)
ClaimWithin implements store.Store. The store's one mutex makes the count of running sessions and the claim one step.
func (*Store) CreateCampaign ¶ added in v0.4.0
CreateCampaign implements store.Store.
func (*Store) DecideApproval ¶
DecideApproval implements store.Store.
func (*Store) DeleteDraft ¶
DeleteDraft implements store.Store.
func (*Store) DeleteMemory ¶
DeleteMemory implements store.Store.
func (*Store) GetApproval ¶
GetApproval implements store.Store.
func (*Store) GetCampaign ¶ added in v0.4.0
GetCampaign implements store.Store.
func (*Store) GetEvalRun ¶
GetEvalRun implements store.Store.
func (*Store) GetProposal ¶
GetProposal implements store.Store.
func (*Store) GetPullRequest ¶
func (s *Store) GetPullRequest(_ context.Context, repo string, number int) (*store.PullRequest, error)
GetPullRequest implements store.Store.
func (*Store) GetRevision ¶
GetRevision implements store.Store.
func (*Store) GetScheduleState ¶
GetScheduleState implements store.Store.
func (*Store) GetSession ¶
GetSession implements store.Store.
func (*Store) ListAudit ¶
func (s *Store) ListAudit(_ context.Context, f store.AuditFilter) ([]store.AuditEntry, error)
ListAudit implements store.Store.
func (*Store) ListCampaigns ¶ added in v0.4.0
ListCampaigns implements store.Store.
func (*Store) ListDrafts ¶
ListDrafts implements store.Store.
func (*Store) ListEvalRuns ¶
ListEvalRuns implements store.Store.
func (*Store) ListMemory ¶
ListMemory implements store.Store.
func (*Store) ListProposals ¶
ListProposals implements store.Store.
func (*Store) ListPullRequests ¶
func (s *Store) ListPullRequests(_ context.Context, f store.PullRequestFilter) ([]store.PullRequest, error)
ListPullRequests implements store.Store.
func (*Store) ListRevisions ¶
func (s *Store) ListRevisions(_ context.Context, scope, object string, limit int) ([]store.Revision, error)
ListRevisions implements store.Store.
func (*Store) ListSessionMessages ¶
func (s *Store) ListSessionMessages(_ context.Context, sessionID string) ([]store.SessionMessage, error)
ListSessionMessages implements store.Store.
func (*Store) ListSessions ¶
ListSessions implements store.Store.
func (*Store) ListSkillIndex ¶
ListSkillIndex implements store.Store.
func (*Store) MarkSessionMessages ¶
func (s *Store) MarkSessionMessages(_ context.Context, sessionID string, ids []string, status, to string) ([]store.SessionMessage, error)
MarkSessionMessages implements store.Store.
func (*Store) PutApproval ¶
PutApproval implements store.Store.
func (*Store) PutEvalRun ¶
PutEvalRun implements store.Store.
func (*Store) PutProposal ¶
PutProposal implements store.Store.
func (*Store) PutRevision ¶
func (s *Store) PutRevision(_ context.Context, r store.Revision, activate bool) (*store.Revision, error)
PutRevision implements store.Store.
func (*Store) PutScheduleState ¶
PutScheduleState implements store.Store.
func (*Store) RecordPullRequest ¶
RecordPullRequest implements store.Store.
func (*Store) Release ¶
func (s *Store) Release(_ context.Context, sessionID, worker string, status store.SessionStatus, runAfter time.Time) error
Release implements store.Store.
func (*Store) ReplaceSkillIndex ¶
func (s *Store) ReplaceSkillIndex(_ context.Context, repo string, entries []store.SkillIndexEntry) error
ReplaceSkillIndex implements store.Store.
func (*Store) RequestCancel ¶
RequestCancel implements store.Store.
func (*Store) SearchMemory ¶
SearchMemory implements store.Store.
func (*Store) SpendByPerson ¶ added in v0.5.0
SpendByPerson implements store.Store.
func (*Store) SpendByRepo ¶ added in v0.3.0
SpendByRepo implements store.Store.
func (*Store) SpendBySkill ¶ added in v0.5.0
SpendBySkill implements store.Store.
func (*Store) SpendSince ¶
SpendSince implements store.Store.
func (*Store) TryUpdateCampaign ¶ added in v0.4.0
func (s *Store) TryUpdateCampaign(ctx context.Context, id string, fn func(*store.Campaign) error) (*store.Campaign, error)
TryUpdateCampaign implements store.Store.
func (*Store) UndeliveredMessages ¶
func (s *Store) UndeliveredMessages(_ context.Context, sessionID string) ([]store.SessionMessage, error)
UndeliveredMessages implements store.Store.
func (*Store) UpdateCampaign ¶ added in v0.4.0
func (s *Store) UpdateCampaign(ctx context.Context, id string, fn func(*store.Campaign) error) (*store.Campaign, error)
UpdateCampaign implements store.Store. Each campaign has a lock of its own, held while fn runs; campMu is not, so fn may call the rest of the store and read campaigns. As store.Store says, fn must not update a campaign: this store would let it update another, Postgres would not.
func (*Store) UpdatePullRequest ¶
UpdatePullRequest implements store.Store.
func (*Store) UpdateSession ¶
UpdateSession implements store.Store.
func (*Store) UpdateStep ¶
UpdateStep implements store.Store.
func (*Store) UpsertUser ¶
UpsertUser implements store.Store.
func (*Store) WatchConfig ¶
WatchConfig implements store.Store.