-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnorm.go
49 lines (39 loc) · 823 Bytes
/
norm.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
39
40
41
42
43
44
45
46
47
48
49
package norm
import (
"context"
"errors"
)
var (
ErrNotFound = errors.New("not found")
ErrNotAffected = errors.New("not affected by create/update")
)
type Creator[M, A any] interface {
Create(ctx context.Context, key A, value M) error
}
type Reader[M, A any] interface {
Read(ctx context.Context, args A) (value M, err error)
}
type Updater[M, A any] interface {
Update(ctx context.Context, args A, value M) error
}
type Deleter[M, A any] interface {
Delete(ctx context.Context, args A) error
}
type Object[M, A any] interface {
Creator[M, A]
Reader[M, A]
Updater[M, A]
Deleter[M, A]
}
type PersistentObject[M, A any] interface {
Creator[M, A]
Reader[M, A]
Updater[M, A]
}
type ImmutableObject[M, A any] interface {
Creator[M, A]
Reader[M, A]
}
type View[M, A any] interface {
Reader[M, A]
}