Skip to content

Commit

Permalink
Use a distinct IterableCtxStore interface
Browse files Browse the repository at this point in the history
  • Loading branch information
alexedwards committed Dec 2, 2021
1 parent 2e73121 commit 1216521
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion data.go
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ func (s *SessionManager) doStoreCommit(ctx context.Context, token string, b []by
}

func (s *SessionManager) doStoreAll(ctx context.Context) (map[string][]byte, error) {
cs, ok := s.Store.(CtxStore)
cs, ok := s.Store.(IterableCtxStore)
if ok {
return cs.AllCtx(ctx)
}
Expand Down
13 changes: 9 additions & 4 deletions store.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,20 @@ type IterableStore interface {
type CtxStore interface {
Store

// DeleteCtx same as Store.Delete, except it takes a context.Context.
// DeleteCtx is the same as Store.Delete, except it takes a context.Context.
DeleteCtx(ctx context.Context, token string) (err error)

// FindCtx same as Store.Find, except it takes a context.Context.
// FindCtx is thesame as Store.Find, except it takes a context.Context.
FindCtx(ctx context.Context, token string) (b []byte, found bool, err error)

// CommitCtx same as Store.Commit, except it takes a context.Context.
// CommitCtx is the same as Store.Commit, except it takes a context.Context.
CommitCtx(ctx context.Context, token string, b []byte, expiry time.Time) (err error)
}

// AllCtx same as IterableStore.All, expect it takes a context.Context.
// IterableCtxStore is the interface for session stores which support iteration
// and which take a context.Context parameter.
type IterableCtxStore interface {
// AllCtx is the same as IterableStore.All, expect it takes a
// context.Context.
AllCtx(ctx context.Context) (map[string][]byte, error)
}

0 comments on commit 1216521

Please sign in to comment.