-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathmain.go
59 lines (55 loc) · 1.43 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-elasticsearch"
"github.com/Trendyol/go-dcp-elasticsearch/config"
"github.com/Trendyol/go-dcp-elasticsearch/couchbase"
"github.com/Trendyol/go-dcp-elasticsearch/elasticsearch/document"
dcpConfig "github.com/Trendyol/go-dcp/config"
)
func mapper(event couchbase.Event) []document.ESActionDocument {
if event.IsMutated {
e := document.NewIndexAction(event.Key, event.Value, nil)
return []document.ESActionDocument{e}
}
e := document.NewDeleteAction(event.Key, nil)
return []document.ESActionDocument{e}
}
func main() {
connector, err := dcpelasticsearch.NewConnectorBuilder(config.Config{
Elasticsearch: config.Elasticsearch{
CollectionIndexMapping: map[string]string{
"_default": "indexname",
},
Urls: []string{"http://localhost:9200"},
},
Dcp: dcpConfig.Dcp{
Username: "user",
Password: "password",
BucketName: "dcp-test",
Hosts: []string{"localhost:8091"},
Dcp: dcpConfig.ExternalDcp{
Group: dcpConfig.DCPGroup{
Name: "groupName",
Membership: dcpConfig.DCPGroupMembership{
Type: "static",
},
},
},
Metadata: dcpConfig.Metadata{
Config: map[string]string{
"bucket": "checkpoint-bucket-name",
"scope": "_default",
"collection": "_default",
},
Type: "couchbase",
},
},
}).
SetMapper(mapper).
Build()
if err != nil {
panic(err)
}
defer connector.Close()
connector.Start()
}