-
Notifications
You must be signed in to change notification settings - Fork 0
/
iface.go
38 lines (28 loc) · 1.09 KB
/
iface.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package repos
import (
"context"
"github.com/fredbi/go-patterns/iterators"
)
type (
MessageIterator = iterators.StructIterator[Message]
// Iface serves interfaces to persistent repositories.
Iface interface {
Messages() MessageRepo
}
// MessageRepo exposes the persistent repository for messages.
MessageRepo interface {
// Create a new Message in the DB
Create(context.Context, Message) error
// Update a Message in the DB.
Update(context.Context, Message, ...UpdateOption) error
// Get retrieves a Message by its unique ID
Get(context.Context, string) (Message, error)
// List Messages using a MessagePredicate filter. The result is an iterator to the
// fetched rows.
List(context.Context, MessagePredicate) (MessageIterator, error)
// UpdateConfirmed is an entry point for consumers to store their own view of the message status
UpdateConfirmed(context.Context, string, MessageStatus) error
// UpdateReplay is an entry point for producer keep track of how many times messages have been replayed
UpdateReplay(context.Context, Message, ...UpdateOption) error
}
)