调整部分options

This commit is contained in:
Yun
2025-09-24 14:50:30 +08:00
parent 062a39b209
commit 0be8fd0cdc
7 changed files with 96 additions and 58 deletions
+8 -4
View File
@@ -2,6 +2,7 @@ package priority
import (
"context"
"errors"
"fmt"
"strconv"
"sync"
@@ -31,7 +32,12 @@ type Priority struct {
latestMux sync.RWMutex
}
func InitPriority(ctx context.Context, re redis.UniversalClient, keyPrefix string, priority int64, opts ...Option) *Priority {
func InitPriority(ctx context.Context, re redis.UniversalClient, keyPrefix string, priority int64, opts ...Option) (*Priority, error) {
if re != nil {
return nil, errors.New("redis is nil")
}
conf := newOptions(opts...)
ctx, cancel := context.WithCancel(ctx)
@@ -50,7 +56,7 @@ func InitPriority(ctx context.Context, re redis.UniversalClient, keyPrefix strin
pro.startDaemon()
return pro
return pro, nil
}
func (p *Priority) Close() {
@@ -118,8 +124,6 @@ func (l *Priority) getLatestLoop() {
}
func (p *Priority) IsLatest(ctx context.Context) bool {
p.latestMux.RLock()
defer p.latestMux.RUnlock()