diff --git a/notifier/mockstore.go b/notifier/mockstore.go index 98fdb455ed..cbc2c48bb9 100644 --- a/notifier/mockstore.go +++ b/notifier/mockstore.go @@ -8,18 +8,18 @@ import ( // MockStore implements a mock Store. type MockStore struct { - Notifications_ func(ctx context.Context, id uuid.UUID, page *Page) ([]Notification, Page, error) - PutNotifications_ func(ctx context.Context, opts PutOpts) error - PutReceipt_ func(ctx context.Context, updater string, r Receipt) error - DeleteNotitfications_ func(ctx context.Context, id uuid.UUID) error - Receipt_ func(ctx context.Context, id uuid.UUID) (Receipt, error) - ReceiptByUOID_ func(ctx context.Context, id uuid.UUID) (Receipt, error) - Created_ func(ctx context.Context) ([]uuid.UUID, error) - Failed_ func(ctx context.Context) ([]uuid.UUID, error) - Deleted_ func(ctx context.Context) ([]uuid.UUID, error) - SetDelivered_ func(ctx context.Context, id uuid.UUID) error - SetDeliveredFailed_ func(ctx context.Context, id uuid.UUID) error - SetDeleted_ func(ctx context.Context, id uuid.UUID) error + Notifications_ func(ctx context.Context, id uuid.UUID, page *Page) ([]Notification, Page, error) + PutNotifications_ func(ctx context.Context, opts PutOpts) error + PutReceipt_ func(ctx context.Context, updater string, r Receipt) error + CollectNotitfications_ func(ctx context.Context) error + Receipt_ func(ctx context.Context, id uuid.UUID) (Receipt, error) + ReceiptByUOID_ func(ctx context.Context, id uuid.UUID) (Receipt, error) + Created_ func(ctx context.Context) ([]uuid.UUID, error) + Failed_ func(ctx context.Context) ([]uuid.UUID, error) + Deleted_ func(ctx context.Context) ([]uuid.UUID, error) + SetDelivered_ func(ctx context.Context, id uuid.UUID) error + SetDeliveredFailed_ func(ctx context.Context, id uuid.UUID) error + SetDeleted_ func(ctx context.Context, id uuid.UUID) error } // Notifications retrieves the list of notifications associated with a @@ -50,15 +50,9 @@ func (m *MockStore) PutReceipt(ctx context.Context, updater string, r Receipt) e return m.PutReceipt_(ctx, updater, r) } -// DeleteNotifications garbage collects all notifications associated -// with a notification id. -// -// Normally Receipter.SetDeleted will be issues first, however -// application logic may decide to gc notifications which have not been -// set deleted after some period of time, thus this condition should not -// be checked. -func (m *MockStore) DeleteNotifications(ctx context.Context, id uuid.UUID) error { - return m.DeleteNotitfications_(ctx, id) +// CollectNotifications garbage collects all notifications. +func (m *MockStore) CollectNotifications(ctx context.Context) error { + return m.CollectNotitfications_(ctx) } // Receipt returns the Receipt for a given notification id diff --git a/notifier/postgres/notifications.go b/notifier/postgres/notifications.go index f7d62a1422..72f8178790 100644 --- a/notifier/postgres/notifications.go +++ b/notifier/postgres/notifications.go @@ -2,6 +2,7 @@ package postgres import ( "context" + "errors" "time" "github.com/google/uuid" @@ -118,3 +119,7 @@ func notifications(ctx context.Context, pool *pgxpool.Pool, id uuid.UUID, page * return notifications, outPage, nil } + +func (*Store) CollectNotifications(ctx context.Context) error { + return errors.New("unimplemented") +} diff --git a/notifier/store.go b/notifier/store.go index 39825dedd7..fcbb765828 100644 --- a/notifier/store.go +++ b/notifier/store.go @@ -58,14 +58,13 @@ type Notificationer interface { // // After this method returns all methods on the Receipter interface must work accordingly. PutReceipt(ctx context.Context, updater string, r Receipt) error - // DeleteNotifications garbage collects all notifications associated - // with a notification id. + // CollectNotifications garbage collects all notifications. // // Normally Receipter.SetDeleted will be issues first, however // application logic may decide to GC notifications which have not been // set deleted after some period of time, thus this condition should not // be checked. - DeleteNotifications(ctx context.Context, id uuid.UUID) error + CollectNotifications(ctx context.Context) error } // Receipter implements persistence methods for Receipt models