Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
shibukazu committed Aug 23, 2024
1 parent 29dd802 commit e8089ce
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
8 changes: 3 additions & 5 deletions go/pkg/server/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,13 +191,11 @@ func (g *Gateway) forwardCheckRequestMiddleware(next http.Handler) http.Handler
}

// Check if the request forward is needed
isForwardNeed := false
if !dslFound {
isForwardNeed = true
} else {
isForwardNeed := true
if dslFound {
for _, validation := range dsl.Validations {
if validation.ID == id {
isForwardNeed = true
isForwardNeed = false
break
}
}
Expand Down
3 changes: 2 additions & 1 deletion go/pkg/slave/manager.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package slave

import (
"fmt"
"log/slog"
"sync"

Expand Down Expand Up @@ -40,5 +41,5 @@ func (m *SlaveManager) FindSlave(validationId string) (*Slave, error) {
}
}
}
return nil, failure.New("slave node that can handle the validation ID is not found")
return nil, failure.New(fmt.Sprintf("slave node that can handle the validation ID (%s) is not found", validationId))
}
7 changes: 6 additions & 1 deletion go/pkg/store/memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package store
import (
"bytes"
"encoding/json"
"strings"
"sync"

"github.com/morikuni/failure/v2"
Expand All @@ -23,7 +24,11 @@ func NewMemoryStore(id string) *MemoryStore {

func (s *MemoryStore) Reset() error {
s.mu.Lock()
s.memory = make(map[string][]byte)
for k := range s.memory {
if strings.HasPrefix(k, s.id+":") {
delete(s.memory, k)
}
}
s.mu.Unlock()
return nil
}
Expand Down
6 changes: 5 additions & 1 deletion go/pkg/store/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ func NewRedisStore(id string, redisClient *redis.Client) *RedisStore {
}

func (s *RedisStore) Reset() error {
if err := s.redisClient.FlushDB().Err(); err != nil {
keys, _ := s.redisClient.Scan(0, s.id+":*", 0).Val()
if len(keys) == 0 {
return nil
}
if err := s.redisClient.Del(keys...).Err(); err != nil {
return failure.Translate(err, appError.ErrRedisOperationFailed)
}
return nil
Expand Down

0 comments on commit e8089ce

Please sign in to comment.