Skip to content

Commit

Permalink
feat: exports broker releated types
Browse files Browse the repository at this point in the history
  • Loading branch information
huangdong.106 committed Dec 3, 2024
1 parent 7986156 commit 6dad2eb
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
25 changes: 25 additions & 0 deletions broker/broker.go
Original file line number Diff line number Diff line change
@@ -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
)
3 changes: 2 additions & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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}
}

Expand Down
3 changes: 2 additions & 1 deletion server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 6dad2eb

Please sign in to comment.