oyeah i dont need redis client if i am parsing protocol
This commit is contained in:
@@ -4,8 +4,6 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
valkey "github.com/redis/go-redis/v9"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
@@ -13,8 +11,6 @@ type Config struct {
|
|||||||
ConnectionDriver string `json:"CONNECTION_DRIVER"`
|
ConnectionDriver string `json:"CONNECTION_DRIVER"`
|
||||||
ConnectionString string `json:"CONNECTION_STRING"`
|
ConnectionString string `json:"CONNECTION_STRING"`
|
||||||
db DB
|
db DB
|
||||||
KeyValueURL string `json:"KEY_VALUE_URL"`
|
|
||||||
keyValue *valkey.Client
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewConfig(ctx context.Context) (Config, error) {
|
func NewConfig(ctx context.Context) (Config, error) {
|
||||||
@@ -23,20 +19,8 @@ func NewConfig(ctx context.Context) (Config, error) {
|
|||||||
return config, err
|
return config, err
|
||||||
}
|
}
|
||||||
|
|
||||||
opt, err := valkey.ParseURL(config.KeyValueURL)
|
|
||||||
if err != nil {
|
|
||||||
return config, err
|
|
||||||
}
|
|
||||||
client := valkey.NewClient(opt)
|
|
||||||
if err := client.Ping(ctx).Err(); err != nil {
|
|
||||||
client.Close()
|
|
||||||
return config, err
|
|
||||||
}
|
|
||||||
config.keyValue = client
|
|
||||||
|
|
||||||
db, err := NewDB(ctx, config.ConnectionDriver, config.ConnectionString)
|
db, err := NewDB(ctx, config.ConnectionDriver, config.ConnectionString)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
client.Close()
|
|
||||||
return config, err
|
return config, err
|
||||||
}
|
}
|
||||||
config.db = db
|
config.db = db
|
||||||
@@ -49,7 +33,6 @@ func newConfig() (Config, error) {
|
|||||||
Listen: ":10000",
|
Listen: ":10000",
|
||||||
ConnectionDriver: "sqlite",
|
ConnectionDriver: "sqlite",
|
||||||
ConnectionString: "/tmp/red-apter.db",
|
ConnectionString: "/tmp/red-apter.db",
|
||||||
KeyValueURL: "redis://localhost:6379",
|
|
||||||
}
|
}
|
||||||
b, _ := json.Marshal(config)
|
b, _ := json.Marshal(config)
|
||||||
var m map[string]any
|
var m map[string]any
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ func Main(ctx context.Context) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer config.db.Close()
|
defer config.db.Close()
|
||||||
defer config.keyValue.Close()
|
|
||||||
|
|
||||||
if err := listen(ctx, config); err != nil && ctx.Err() == nil {
|
if err := listen(ctx, config); err != nil && ctx.Err() == nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
Reference in New Issue
Block a user