From 12165213346f24f731a5b8f0e064dc41fea05935 Mon Sep 17 00:00:00 2001 From: Alex Edwards Date: Thu, 2 Dec 2021 18:29:12 +0100 Subject: [PATCH] Use a distinct IterableCtxStore interface --- data.go | 2 +- store.go | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/data.go b/data.go index 245790a..5b12481 100644 --- a/data.go +++ b/data.go @@ -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) } diff --git a/store.go b/store.go index 4fefaf9..b59bc75 100644 --- a/store.go +++ b/store.go @@ -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) }