From df6cfa0b7a982a178565d3ca45a62cf6d1826b01 Mon Sep 17 00:00:00 2001 From: Eric Chiang Date: Wed, 12 Oct 2016 18:46:10 -0700 Subject: [PATCH] storage: add GC method to interface to standardize handling --- storage/storage.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/storage/storage.go b/storage/storage.go index 78c162f9..032ba4ed 100644 --- a/storage/storage.go +++ b/storage/storage.go @@ -38,6 +38,12 @@ func NewID() string { return strings.TrimRight(encoding.EncodeToString(buff), "=") } +// GCResult returns the number of objects deleted by garbage collection. +type GCResult struct { + AuthRequests int64 + AuthCodes int64 +} + // Storage is the storage interface used by the server. Implementations, at minimum // require compare-and-swap atomic actions. // @@ -80,8 +86,8 @@ type Storage interface { UpdateAuthRequest(id string, updater func(a AuthRequest) (AuthRequest, error)) error UpdatePassword(email string, updater func(p Password) (Password, error)) error - // TODO(ericchiang): Add a GarbageCollect(now time.Time) method so conformance tests - // can test implementations. + // GarbageCollect deletes all expired AuthCodes and AuthRequests. + GarbageCollect(now time.Time) (GCResult, error) } // Client represents an OAuth2 client.