-
Notifications
You must be signed in to change notification settings - Fork 16
/
main.go
59 lines (55 loc) · 1.32 KB
/
main.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
56
57
58
59
package main
import (
"github.com/Trendyol/go-dcp-kafka"
"github.com/Trendyol/go-dcp-kafka/config"
"github.com/Trendyol/go-dcp-kafka/couchbase"
"github.com/Trendyol/go-dcp-kafka/kafka/message"
dcpConfig "github.com/Trendyol/go-dcp/config"
"time"
)
func mapper(event couchbase.Event) []message.KafkaMessage {
// return nil if you wish to discard the event
return []message.KafkaMessage{
{
Headers: nil,
Key: event.Key,
Value: event.Value,
},
}
}
func main() {
c, err := dcpkafka.NewConnectorBuilder(&config.Connector{
Dcp: dcpConfig.Dcp{
Hosts: []string{"localhost:8091"},
Username: "user",
Password: "password",
BucketName: "dcp-test",
Dcp: dcpConfig.ExternalDcp{
Group: dcpConfig.DCPGroup{
Name: "groupName",
Membership: dcpConfig.DCPGroupMembership{
RebalanceDelay: 3 * time.Second,
},
},
},
Metadata: dcpConfig.Metadata{
Config: map[string]string{
"bucket": "checkpoint-bucket-name",
"scope": "_default",
"collection": "_default",
},
Type: "couchbase",
},
Debug: true},
Kafka: config.Kafka{
CollectionTopicMapping: map[string]string{"_default": "topic"},
Brokers: []string{"localhost:9092"},
},
}).SetMapper(mapper).
Build()
if err != nil {
panic(err)
}
defer c.Close()
c.Start()
}