Renamed redis file
This commit is contained in:
parent
53e2254795
commit
74e03bda74
1 changed files with 5 additions and 3 deletions
|
@ -2,9 +2,9 @@ package lib
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"log"
|
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
|
"github.com/fatih/color"
|
||||||
"github.com/joho/godotenv"
|
"github.com/joho/godotenv"
|
||||||
"github.com/redis/go-redis/v9"
|
"github.com/redis/go-redis/v9"
|
||||||
"goth.stack/lib/pubsub"
|
"goth.stack/lib/pubsub"
|
||||||
|
@ -30,7 +30,7 @@ func NewRedisClient() *redis.Client {
|
||||||
redis_host := os.Getenv("REDIS_HOST")
|
redis_host := os.Getenv("REDIS_HOST")
|
||||||
redis_password := os.Getenv("REDIS_PASSWORD")
|
redis_password := os.Getenv("REDIS_PASSWORD")
|
||||||
|
|
||||||
log.Printf("Connecting to Redis at %s", redis_host)
|
LogInfo.Printf("Connecting to Redis at %s", redis_host)
|
||||||
RedisClient = redis.NewClient(&redis.Options{
|
RedisClient = redis.NewClient(&redis.Options{
|
||||||
Addr: redis_host,
|
Addr: redis_host,
|
||||||
Password: redis_password,
|
Password: redis_password,
|
||||||
|
@ -45,7 +45,7 @@ func (m *RedisPubSubMessage) ReceiveMessage(ctx context.Context) (*pubsub.Messag
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
LogInfo.Printf("[PUBSUB/REDIS] Received message: %s", msg.Payload)
|
||||||
return &pubsub.Message{Payload: msg.Payload}, nil
|
return &pubsub.Message{Payload: msg.Payload}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,6 +55,7 @@ func (ps *RedisPubSub) SubscribeToChannel(channel string) (pubsub.PubSubMessage,
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
LogInfo.Printf("[PUBSUB/REDIS] Subscribed to channel %s", channel)
|
||||||
|
|
||||||
return &RedisPubSubMessage{pubsub: pubsub}, nil
|
return &RedisPubSubMessage{pubsub: pubsub}, nil
|
||||||
}
|
}
|
||||||
|
@ -64,5 +65,6 @@ func (r *RedisPubSub) PublishToChannel(channel string, message string) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
color.Cyan("[PUBSUB/REDIS] Publishing message to channel %s: %s", channel, message)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue