common/pkg/subscribe/client.go
2024-08-29 20:38:48 +08:00

22 lines
336 B
Go

package subscribe
import (
"context"
"github.com/redis/go-redis/v9"
)
type Client struct {
rdb *redis.Client
}
func NewClient(rdb *redis.Client) *Client {
return &Client{
rdb: rdb,
}
}
func (c *Client) Publish(ctx context.Context, channel string, message string) error {
return c.rdb.Publish(ctx, channel, message).Err()
}