Skip to content

Commit

Permalink
chore: remove error kit
Browse files Browse the repository at this point in the history
  • Loading branch information
zenghur committed Apr 26, 2020
1 parent 70936a0 commit 83cd857
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
8 changes: 0 additions & 8 deletions errorkit/error.go

This file was deleted.

9 changes: 4 additions & 5 deletions redispattern/lockguard/lock_guard.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"time"

"github.com/xiaojiaoyu100/lizard/backoff"
"github.com/xiaojiaoyu100/lizard/errorkit"
)

const (
Expand Down Expand Up @@ -40,7 +39,7 @@ func New(redis rediser, key string, setters ...Setter) (*LockGuard, error) {
redis: redis,
Key: key,
Value: "",
retryTimes: 3,
retryTimes: 1,
expiration: 30 * time.Second,
}
for _, setter := range setters {
Expand All @@ -54,8 +53,8 @@ func New(redis rediser, key string, setters ...Setter) (*LockGuard, error) {

// Run 锁住
func (guard *LockGuard) Run(ctx context.Context, handler Handler) error {
guard.reset()
for i := 0; i < guard.lock.retryTimes; i++ {
guard.reset()
guard.obtain()
if !guard.lock.locked {
if guard.lock.retryTimes > 1 {
Expand All @@ -77,9 +76,9 @@ func (guard *LockGuard) Run(ctx context.Context, handler Handler) error {
if r := recover(); r != nil {
close(stop)
if _, ok := r.(error); ok {
errChan <- errorkit.WithStack(r.(error))
errChan <- fmt.Errorf("%w", r.(error))
} else {
errChan <- errorkit.WithStack(fmt.Errorf("%+v", r))
errChan <- fmt.Errorf("%+v", r)
}
return
}
Expand Down

0 comments on commit 83cd857

Please sign in to comment.