Skip to content

Commit c0e47b7

Browse files
authored
Merge pull request #22 from zerodha/refactor
Fully refactor the codebase. This is a breaking major version change.
2 parents 38d15df + 6156bde commit c0e47b7

18 files changed

+2133
-2064
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ go.work
2222
config.toml
2323
/dist
2424
kaf-relay.bin
25+
kaf-relay

.goreleaser.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ builds:
1616
archives:
1717
- format: tar.gz
1818
files:
19-
- config.toml.sample
19+
- config.sample.toml
2020
- README.md
2121
- LICENSE

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ BIN := kaf-relay
1010
.PHONY: build
1111
build: $(BIN)
1212

13-
$(BIN):
13+
$(BIN): $(shell find . -type f -name "*.go") go.mod go.sum
1414
CGO_ENABLED=0 go build -o ${BIN} --ldflags="-X 'main.buildString=${BUILDSTR}'"
1515

1616
.PHONY: clean

config.go

Lines changed: 0 additions & 104 deletions
This file was deleted.

config.sample.toml

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
[app]
2+
log_level = "debug"
3+
metrics_server_addr = ":7081"
4+
5+
6+
# Map of topics from the source to sync to the target.
7+
# source_topic => target_topic:optional_target_partition
8+
# If the target partition is not specified, whatever partition a message
9+
# was received from the source, the same partition is written to the target.
10+
[[topics]]
11+
source_topic1 = "target_topic1:1"
12+
source_topic2 = "target_topic2"
13+
14+
15+
[source_pool]
16+
# Kafka client config common to all upstream sources ([[sources]]).
17+
initial_offset = "start"
18+
instance_id = "client_instance_id"
19+
group_id = "consumer_group"
20+
21+
# Frequency at which source servers are polled for health/lag.
22+
healthcheck_interval = "3s"
23+
24+
# Max difference in total offsets across all topics on a source
25+
# against other sources, which when breached, the source is marked
26+
# as unhealthy because of a lag.
27+
offset_lag_threshold = 1000
28+
29+
# Maximum number of connect/fetch retries before exiting. -1 for infinite.
30+
max_retries = -1
31+
32+
# Kafka exponential retry-backoff config for reconnection attempts.
33+
# If both min and max values are the same, then it's a static wait time
34+
# between attempts.
35+
backoff_enable = true
36+
backoff_min = "2s"
37+
backoff_max = "10s"
38+
39+
# Wait timeout of a request/response to a Kafka instance to determine
40+
# whether it's healthy or not.
41+
request_timeout = "100ms"
42+
43+
44+
[[sources]]
45+
name = "node1"
46+
servers = ["127.0.0.1:9092"]
47+
session_timeout = "6s"
48+
enable_auth = true
49+
sasl_mechanism = "PLAIN"
50+
username = "user-x"
51+
password = "pass-x"
52+
max_wait_time = "10ms"
53+
max_failovers = -1 # infinite
54+
55+
enable_tls = false
56+
client_key_path = ""
57+
client_cert_path = ""
58+
ca_cert_path = ""
59+
60+
enable_log = false
61+
62+
[[sources]]
63+
name = "node2"
64+
servers = ["node2:9092"]
65+
session_timeout = "6s"
66+
enable_auth = true
67+
sasl_mechanism = "PLAIN"
68+
username = "user-x"
69+
password = "pass-x"
70+
max_wait_time = "10ms"
71+
max_failovers = -1 # infinite
72+
73+
enable_tls = false
74+
client_key_path = ""
75+
client_cert_path = ""
76+
ca_cert_path = ""
77+
78+
enable_log = false
79+
80+
81+
# Destination kafka producer configuration
82+
[target]
83+
name = "node3"
84+
servers = ["127.0.0.1:9095"]
85+
enable_log = false
86+
enable_auth = true
87+
sasl_mechanism = "PLAIN" # PLAIN/SCRAM-SHA-256/SCRAM-SHA-512
88+
username = "user-y"
89+
password = "pass-y"
90+
enable_idempotency = true
91+
commit_ack_type = "cluster"
92+
flush_frequency = "20ms"
93+
session_timeout = "6s"
94+
95+
enable_tls = false
96+
client_key_path = ""
97+
client_cert_path = ""
98+
ca_cert_path = ""
99+
100+
# -1 for infinite.
101+
max_retries = -1
102+
flush_batch_size = 1000
103+
batch_size = 1000
104+
max_message_bytes = 10000000
105+
106+
# Kafka exponential retry-backoff config for reconnection attempts.
107+
# If both min and max values are the same, then it's a static wait time
108+
# between attempts.
109+
backoff_enable = true
110+
backoff_min = "2s"
111+
backoff_max = "10s"
112+
113+
# Wait timeout of a request/response to a Kafka instance to determine
114+
# whether it's healthy or not.
115+
request_timeout = "100ms"
116+
117+
118+
# Custom go-plugin filter to load to filter messages when relaying
119+
[filters.test]
120+
enabled = false
121+
path = "test.bin"
122+
config = '''
123+
{
124+
"address": ["127.0.0.1:6379"],
125+
"username": "",
126+
"password": "",
127+
"db": 10,
128+
"max_active": 50,
129+
"max_idle": 20,
130+
"dial_timeout": 3000,
131+
"read_timeout": 3000,
132+
"write_timeout": 3000,
133+
"idle_timeout": 30000
134+
}
135+
'''

config.toml.sample

Lines changed: 0 additions & 120 deletions
This file was deleted.

0 commit comments

Comments
 (0)