storage: add GC method to interface to standardize handling

This commit is contained in:
Eric Chiang 2016-10-12 18:46:10 -07:00
parent cf8801dcec
commit df6cfa0b7a

View file

@ -38,6 +38,12 @@ func NewID() string {
return strings.TrimRight(encoding.EncodeToString(buff), "=") 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 // Storage is the storage interface used by the server. Implementations, at minimum
// require compare-and-swap atomic actions. // require compare-and-swap atomic actions.
// //
@ -80,8 +86,8 @@ type Storage interface {
UpdateAuthRequest(id string, updater func(a AuthRequest) (AuthRequest, error)) error UpdateAuthRequest(id string, updater func(a AuthRequest) (AuthRequest, error)) error
UpdatePassword(email string, updater func(p Password) (Password, error)) error UpdatePassword(email string, updater func(p Password) (Password, error)) error
// TODO(ericchiang): Add a GarbageCollect(now time.Time) method so conformance tests // GarbageCollect deletes all expired AuthCodes and AuthRequests.
// can test implementations. GarbageCollect(now time.Time) (GCResult, error)
} }
// Client represents an OAuth2 client. // Client represents an OAuth2 client.