2
0
mirror of https://github.com/hibiken/asynq.git synced 2024-12-25 07:12:17 +08:00

feat: exports broker releated types

This commit is contained in:
huangdong.106 2024-12-03 21:53:19 +08:00
parent 7986156ac4
commit 6dad2eb6d7
3 changed files with 29 additions and 2 deletions

25
broker/broker.go Normal file
View File

@ -0,0 +1,25 @@
package broker
import (
"github.com/hibiken/asynq/internal/base"
"github.com/hibiken/asynq/internal/rdb"
)
// This package exports the same types as the internal package.
// This is a temporary solution until we can move the these types out of internal.
type (
TaskMessage = base.TaskMessage
WorkerInfo = base.WorkerInfo
ServerInfo = base.ServerInfo
Broker = base.Broker
CancellationSubscription = base.CancellationSubscription
RDB = rdb.RDB
)
var (
NewRDB = rdb.NewRDB
)

View File

@ -11,6 +11,7 @@ import (
"time"
"github.com/google/uuid"
"github.com/hibiken/asynq/broker"
"github.com/hibiken/asynq/internal/base"
"github.com/hibiken/asynq/internal/errors"
"github.com/hibiken/asynq/internal/rdb"
@ -49,7 +50,7 @@ func NewClientFromRedisClient(c redis.UniversalClient) *Client {
// NewClientFromBroker returns a new instance of Client given a broker.
// Warning: The underlying broker will not be closed by Asynq, you are responsible for closing it.
func NewClientFromBroker(b base.Broker) *Client {
func NewClientFromBroker(b broker.Broker) *Client {
return &Client{broker: b, sharedConnection: true}
}

View File

@ -15,6 +15,7 @@ import (
"sync"
"time"
"github.com/hibiken/asynq/broker"
"github.com/hibiken/asynq/internal/base"
"github.com/hibiken/asynq/internal/log"
"github.com/hibiken/asynq/internal/rdb"
@ -449,7 +450,7 @@ func NewServerFromRedisClient(c redis.UniversalClient, cfg Config) *Server {
// NewServerFromBroker returns a new instance of Server given a Broker and server configuration.
// Warning: The underlying broker will not be closed by Asynq, you are responsible for closing it.
func NewServerFromBroker(b base.Broker, cfg Config) *Server {
func NewServerFromBroker(b broker.Broker, cfg Config) *Server {
baseCtxFn := cfg.BaseContext
if baseCtxFn == nil {
baseCtxFn = context.Background