mirror of
https://github.com/hibiken/asynq.git
synced 2025-02-22 20:00:19 +08:00
docs: apply recommendaded updates
* additionally, we log an erro in the case the redis client cannot shutdown in the scheduler
This commit is contained in:
parent
5daa3c52ed
commit
461d922616
@ -41,8 +41,8 @@ func NewClient(r RedisConnOpt) *Client {
|
|||||||
return client
|
return client
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewClientFromRedisClient returns a new Client instance given a redis client.
|
// NewClientFromRedisClient returns a new instance of Client given a redis.UniversalClient
|
||||||
// Warning: the redis client will not be closed by Asynq, you are responsible for closing.
|
// Warning: The underlying redis connection pool will not be closed by Asynq, you are responsible for closing it.
|
||||||
func NewClientFromRedisClient(c redis.UniversalClient) *Client {
|
func NewClientFromRedisClient(c redis.UniversalClient) *Client {
|
||||||
return &Client{broker: rdb.NewRDB(c), sharedConnection: true}
|
return &Client{broker: rdb.NewRDB(c), sharedConnection: true}
|
||||||
}
|
}
|
||||||
|
@ -36,8 +36,8 @@ func NewInspector(r RedisConnOpt) *Inspector {
|
|||||||
return inspector
|
return inspector
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewFromRedisClient returns a new instance of Inspector.
|
// NewInspectorFromRedisClient returns a new instance of Inspector given a redis.UniversalClient
|
||||||
// Warning: the redis client will not be closed by Asynq, you are responsible for closing.
|
// Warning: The underlying redis connection pool will not be closed by Asynq, you are responsible for closing it.
|
||||||
func NewInspectorFromRedisClient(c redis.UniversalClient) *Inspector {
|
func NewInspectorFromRedisClient(c redis.UniversalClient) *Inspector {
|
||||||
return &Inspector{
|
return &Inspector{
|
||||||
rdb: rdb.NewRDB(c),
|
rdb: rdb.NewRDB(c),
|
||||||
|
@ -60,9 +60,9 @@ func NewScheduler(r RedisConnOpt, opts *SchedulerOpts) *Scheduler {
|
|||||||
return scheduler
|
return scheduler
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewSchedulerFromRedisClient returns a new Scheduler instance given a redis client.
|
// NewSchedulerFromRedisClient returns a new instance of Scheduler given a redis.UniversalClient
|
||||||
// The parameter opts is optional, defaults will be used if opts is set to nil.
|
// The parameter opts is optional, defaults will be used if opts is set to nil.
|
||||||
// Warning: the redis client will not be closed by Asynq, you are responsible for closing.
|
// Warning: The underlying redis connection pool will not be closed by Asynq, you are responsible for closing it.
|
||||||
func NewSchedulerFromRedisClient(c redis.UniversalClient, opts *SchedulerOpts) *Scheduler {
|
func NewSchedulerFromRedisClient(c redis.UniversalClient, opts *SchedulerOpts) *Scheduler {
|
||||||
if opts == nil {
|
if opts == nil {
|
||||||
opts = &SchedulerOpts{}
|
opts = &SchedulerOpts{}
|
||||||
@ -273,7 +273,9 @@ func (s *Scheduler) Shutdown() {
|
|||||||
s.wg.Wait()
|
s.wg.Wait()
|
||||||
|
|
||||||
s.clearHistory()
|
s.clearHistory()
|
||||||
s.client.Close()
|
if err := s.client.Close(); err != nil {
|
||||||
|
s.logger.Errorf("Failed to close redis client connection: %v", err)
|
||||||
|
}
|
||||||
if !s.sharedConnection {
|
if !s.sharedConnection {
|
||||||
s.rdb.Close()
|
s.rdb.Close()
|
||||||
}
|
}
|
||||||
|
@ -440,9 +440,9 @@ func NewServer(r RedisConnOpt, cfg Config) *Server {
|
|||||||
return server
|
return server
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewServerFromRedisClient returns a new Server given a redis client
|
// NewServerFromRedisClient returns a new instance of Server given a redis.UniversalClient
|
||||||
// and server configuration.
|
// and server configuration
|
||||||
// Warning: the redis client will not be closed by Asynq, you are responsible for closing.
|
// Warning: The underlying redis connection pool will not be closed by Asynq, you are responsible for closing it.
|
||||||
func NewServerFromRedisClient(c redis.UniversalClient, cfg Config) *Server {
|
func NewServerFromRedisClient(c redis.UniversalClient, cfg Config) *Server {
|
||||||
baseCtxFn := cfg.BaseContext
|
baseCtxFn := cfg.BaseContext
|
||||||
if baseCtxFn == nil {
|
if baseCtxFn == nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user