-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.go
More file actions
78 lines (71 loc) · 1.66 KB
/
Copy pathmain.go
File metadata and controls
78 lines (71 loc) · 1.66 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package main
import (
"context"
"log/slog"
"os"
pgredis "go-dcp-pg-redis"
connconfig "go-dcp-pg-redis/config"
cdcconfig "github.com/Trendyol/go-pq-cdc/config"
"github.com/Trendyol/go-pq-cdc/pq/publication"
"github.com/Trendyol/go-pq-cdc/pq/slot"
)
func main() {
ctx := context.Background()
cfg := &connconfig.Connector{
Postgres: cdcconfig.Config{
Host: "127.0.0.1",
Port: 5433,
Username: "cdc_user",
Password: "cdc_pass",
Database: "cdc_db",
DebugMode: false,
Publication: publication.Config{
CreateIfNotExists: true,
Name: "cdc_publication",
Operations: publication.Operations{
publication.OperationInsert,
publication.OperationDelete,
publication.OperationUpdate,
},
Tables: publication.Tables{
{
Name: "users",
ReplicaIdentity: publication.ReplicaIdentityFull,
Schema: "public",
},
},
},
Slot: slot.Config{
CreateIfNotExists: true,
Name: "cdc_slot_pg_redis",
SlotActivityCheckerInterval: 3000,
},
Metric: cdcconfig.MetricConfig{
Port: 8081,
},
Logger: cdcconfig.LoggerConfig{
LogLevel: slog.LevelInfo,
},
},
Redis: connconfig.Redis{
Host: "127.0.0.1",
Port: 6379,
TableKeyMapping: []connconfig.TableKeyMapping{
{
Schema: "public",
Table: "users",
KeyPrefix: "user:",
KeyColumn: "id",
StorageType: "json",
},
},
},
}
conn, err := pgredis.NewConnectorBuilder(cfg).Build(ctx)
if err != nil {
slog.Error("connector build failed", "error", err)
os.Exit(1)
}
defer conn.Close()
conn.Start(ctx)
}