Template
1
0
Fork 0

Renamed redis file

This commit is contained in:
Atridad Lahiji 2024-02-06 18:45:41 -07:00
parent 53e2254795
commit 74e03bda74
No known key found for this signature in database

View file

@ -2,9 +2,9 @@ package lib
import (
"context"
"log"
"os"
"github.com/fatih/color"
"github.com/joho/godotenv"
"github.com/redis/go-redis/v9"
"goth.stack/lib/pubsub"
@ -30,7 +30,7 @@ func NewRedisClient() *redis.Client {
redis_host := os.Getenv("REDIS_HOST")
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{
Addr: redis_host,
Password: redis_password,
@ -45,7 +45,7 @@ func (m *RedisPubSubMessage) ReceiveMessage(ctx context.Context) (*pubsub.Messag
if err != nil {
return nil, err
}
LogInfo.Printf("[PUBSUB/REDIS] Received message: %s", msg.Payload)
return &pubsub.Message{Payload: msg.Payload}, nil
}
@ -55,6 +55,7 @@ func (ps *RedisPubSub) SubscribeToChannel(channel string) (pubsub.PubSubMessage,
if err != nil {
return nil, err
}
LogInfo.Printf("[PUBSUB/REDIS] Subscribed to channel %s", channel)
return &RedisPubSubMessage{pubsub: pubsub}, nil
}
@ -64,5 +65,6 @@ func (r *RedisPubSub) PublishToChannel(channel string, message string) error {
if err != nil {
return err
}
color.Cyan("[PUBSUB/REDIS] Publishing message to channel %s: %s", channel, message)
return nil
}