common/pkg/subscribe/client.go

22 lines
336 B
Go
Raw Permalink Normal View History

2024-08-29 20:38:48 +08:00
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()
}