22 lines
336 B
Go
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()
|
||
|
}
|