-
Notifications
You must be signed in to change notification settings - Fork 4
/
kafka.go
55 lines (42 loc) · 1.03 KB
/
kafka.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
50
51
52
53
54
55
package kafkamock
import (
"context"
"github.com/Interhyp/metadata-service/internal/acorn/repository"
)
import _ "github.com/go-git/go-git/v5"
type Impl struct {
Callback repository.ReceiverCallback
Recording []repository.UpdateEvent
}
func New() repository.Kafka {
return &Impl{
Callback: func(_ repository.UpdateEvent) {},
Recording: make([]repository.UpdateEvent, 0),
}
}
func (r *Impl) IsKafka() bool {
return true
}
func (r *Impl) Setup() error {
return nil
}
func (r *Impl) Teardown() {
}
func (r *Impl) SubscribeIncoming(_ context.Context, callback repository.ReceiverCallback) error {
r.Callback = callback
return nil
}
func (r *Impl) Send(_ context.Context, event repository.UpdateEvent) error {
r.Recording = append(r.Recording, event)
return nil
}
func (r *Impl) StartReceiveLoop(ctx context.Context) error {
return nil
}
// --- test helpers ---
func (r *Impl) Receive(incomingEvent repository.UpdateEvent) {
r.Callback(incomingEvent)
}
func (r *Impl) Reset() {
r.Recording = make([]repository.UpdateEvent, 0)
}