feat: optimize job new in internal (#2341)
Signed-off-by: Gaius <gaius.qi@gmail.com>
This commit is contained in:
parent
602206495a
commit
b80b4acbe4
|
|
@ -53,16 +53,6 @@ func New(cfg *Config, queue Queue) (*Job, error) {
|
||||||
// Set logger
|
// Set logger
|
||||||
machineryv1log.Set(&MachineryLogger{})
|
machineryv1log.Set(&MachineryLogger{})
|
||||||
|
|
||||||
if err := ping(&redis.UniversalOptions{
|
|
||||||
Addrs: cfg.Addrs,
|
|
||||||
MasterName: cfg.MasterName,
|
|
||||||
Username: cfg.Username,
|
|
||||||
Password: cfg.Password,
|
|
||||||
DB: cfg.BrokerDB,
|
|
||||||
}); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := ping(&redis.UniversalOptions{
|
if err := ping(&redis.UniversalOptions{
|
||||||
Addrs: cfg.Addrs,
|
Addrs: cfg.Addrs,
|
||||||
MasterName: cfg.MasterName,
|
MasterName: cfg.MasterName,
|
||||||
|
|
@ -98,8 +88,7 @@ func New(cfg *Config, queue Queue) (*Job, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func ping(options *redis.UniversalOptions) error {
|
func ping(options *redis.UniversalOptions) error {
|
||||||
client := redis.NewUniversalClient(options)
|
return redis.NewUniversalClient(options).Ping(context.Background()).Err()
|
||||||
return client.Ping(context.Background()).Err()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Job) RegisterJob(namedJobFuncs map[string]any) error {
|
func (t *Job) RegisterJob(namedJobFuncs map[string]any) error {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue