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:
parent
7986156ac4
commit
6dad2eb6d7
25
broker/broker.go
Normal file
25
broker/broker.go
Normal 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
|
||||||
|
)
|
@ -11,6 +11,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
|
"github.com/hibiken/asynq/broker"
|
||||||
"github.com/hibiken/asynq/internal/base"
|
"github.com/hibiken/asynq/internal/base"
|
||||||
"github.com/hibiken/asynq/internal/errors"
|
"github.com/hibiken/asynq/internal/errors"
|
||||||
"github.com/hibiken/asynq/internal/rdb"
|
"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.
|
// 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.
|
// 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}
|
return &Client{broker: b, sharedConnection: true}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/hibiken/asynq/broker"
|
||||||
"github.com/hibiken/asynq/internal/base"
|
"github.com/hibiken/asynq/internal/base"
|
||||||
"github.com/hibiken/asynq/internal/log"
|
"github.com/hibiken/asynq/internal/log"
|
||||||
"github.com/hibiken/asynq/internal/rdb"
|
"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.
|
// 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.
|
// 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
|
baseCtxFn := cfg.BaseContext
|
||||||
if baseCtxFn == nil {
|
if baseCtxFn == nil {
|
||||||
baseCtxFn = context.Background
|
baseCtxFn = context.Background
|
||||||
|
Loading…
Reference in New Issue
Block a user