Skip to content

Commit 20dc471

Browse files
committed
Kafka + Redis
1 parent 64aaec5 commit 20dc471

File tree

6 files changed

+319
-620
lines changed

6 files changed

+319
-620
lines changed

configs/config.go

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,19 @@ type PostgresConfig struct {
101101
ConnectTimeout int `mapstructure:"connectTimeout"`
102102
}
103103

104+
type RedisConfig struct {
105+
Host string `mapstructure:"host"`
106+
Port int `mapstructure:"port"`
107+
Password string `mapstructure:"password"`
108+
DB int `mapstructure:"db"`
109+
}
110+
104111
type KafkaConfig struct {
105-
Brokers string `mapstructure:"brokers"`
106-
Username string `mapstructure:"username"`
107-
Password string `mapstructure:"password"`
108-
EnableTLS bool `mapstructure:"enable_tls"`
109-
Postgres *PostgresConfig `mapstructure:"postgres"`
112+
Brokers string `mapstructure:"brokers"`
113+
Username string `mapstructure:"username"`
114+
Password string `mapstructure:"password"`
115+
EnableTLS bool `mapstructure:"enable_tls"`
116+
Redis *RedisConfig `mapstructure:"redis"`
110117
}
111118

112119
type RPCBatchRequestConfig struct {

go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ require (
3939
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
4040
github.com/deckarep/golang-set/v2 v2.6.0 // indirect
4141
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect
42+
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
4243
github.com/ethereum/c-kzg-4844/v2 v2.1.0 // indirect
4344
github.com/ethereum/go-verkle v0.2.2 // indirect
4445
github.com/fsnotify/fsnotify v1.7.0 // indirect
@@ -85,6 +86,7 @@ require (
8586
github.com/prometheus/client_model v0.6.1 // indirect
8687
github.com/prometheus/common v0.55.0 // indirect
8788
github.com/prometheus/procfs v0.15.1 // indirect
89+
github.com/redis/go-redis/v9 v9.12.1 // indirect
8890
github.com/rivo/uniseg v0.2.0 // indirect
8991
github.com/sagikazarmark/locafero v0.4.0 // indirect
9092
github.com/sagikazarmark/slog-shim v0.1.0 // indirect

go.sum

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ github.com/decred/dcrd/crypto/blake256 v1.0.0 h1:/8DMNYp9SGi5f0w7uCm6d6M4OU2rGFK
6363
github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc=
6464
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 h1:YLtO71vCjJRCBcrPMtQ9nqBsqpA1m5sE92cU+pd5Mcc=
6565
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs=
66+
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
67+
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
6668
github.com/ethereum/c-kzg-4844/v2 v2.1.0 h1:gQropX9YFBhl3g4HYhwE70zq3IHFRgbbNPw0Shwzf5w=
6769
github.com/ethereum/c-kzg-4844/v2 v2.1.0/go.mod h1:TC48kOKjJKPbN7C++qIgt0TJzZ70QznYR7Ob+WXl57E=
6870
github.com/ethereum/go-ethereum v1.15.11 h1:JK73WKeu0WC0O1eyX+mdQAVHUV+UR1a9VB/domDngBU=
@@ -237,6 +239,8 @@ github.com/prometheus/common v0.55.0 h1:KEi6DK7lXW/m7Ig5i47x0vRzuBsHuvJdi5ee6Y3G
237239
github.com/prometheus/common v0.55.0/go.mod h1:2SECS4xJG1kd8XF9IcM1gMX6510RAEL65zxzNImwdc8=
238240
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
239241
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
242+
github.com/redis/go-redis/v9 v9.12.1 h1:k5iquqv27aBtnTm2tIkROUDp8JBXhXZIVu1InSgvovg=
243+
github.com/redis/go-redis/v9 v9.12.1/go.mod h1:huWgSWd8mW6+m0VPhJjSSQ+d6Nh1VICQ6Q5lHuCH/Iw=
240244
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
241245
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
242246
github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8=

internal/storage/connector.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ func NewConnector[T any](cfg *config.StorageConnectionConfig) (T, error) {
149149
var conn interface{}
150150
var err error
151151
if cfg.Kafka != nil {
152-
conn, err = NewKafkaPostgresConnector(cfg.Kafka)
152+
conn, err = NewKafkaRedisConnector(cfg.Kafka)
153153
} else if cfg.Postgres != nil {
154154
conn, err = NewPostgresConnector(cfg.Postgres)
155155
} else if cfg.Clickhouse != nil {

0 commit comments

Comments
 (0)