Skip to content

Commit

Permalink
polishing
Browse files Browse the repository at this point in the history
  • Loading branch information
sanzmauro committed Nov 22, 2024
1 parent c7bc7b4 commit a7e24cf
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/gin-gonic/gin v1.10.0
github.com/google/uuid v1.3.0
github.com/splitio/gincache v1.0.1
github.com/splitio/go-split-commons/v6 v6.0.2-0.20241119171952-0b46694a2941
github.com/splitio/go-split-commons/v6 v6.0.2-0.20241122192419-cc8d0413fa8e
github.com/splitio/go-toolkit/v5 v5.4.0
github.com/stretchr/testify v1.9.0
go.etcd.io/bbolt v1.3.6
Expand Down
8 changes: 2 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,8 @@ github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUA
github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE=
github.com/splitio/gincache v1.0.1 h1:dLYdANY/BqH4KcUMCe/LluLyV5WtuE/LEdQWRE06IXU=
github.com/splitio/gincache v1.0.1/go.mod h1:CcgJDSM9Af75kyBH0724v55URVwMBuSj5x1eCWIOECY=
github.com/splitio/go-split-commons/v6 v6.0.1 h1:WJcvTk8lwWw6kLQvxt8hOkY/tGlBN4w+2agkINPGugY=
github.com/splitio/go-split-commons/v6 v6.0.1/go.mod h1:TsvIh3XP7yjc7ly4vpj06AkoBND36SodPs5qfhb8rHc=
github.com/splitio/go-split-commons/v6 v6.0.2-0.20241115210219-e8964f13d489 h1:9sr63h4Kco1TSPtwaiECfRYfNvDMYtvQL2q4r62drDo=
github.com/splitio/go-split-commons/v6 v6.0.2-0.20241115210219-e8964f13d489/go.mod h1:TsvIh3XP7yjc7ly4vpj06AkoBND36SodPs5qfhb8rHc=
github.com/splitio/go-split-commons/v6 v6.0.2-0.20241119171952-0b46694a2941 h1:Rzpm7u9uIaTsQDvSWRPsMbmBpZeg2kUQkVt0+30ubj4=
github.com/splitio/go-split-commons/v6 v6.0.2-0.20241119171952-0b46694a2941/go.mod h1:TsvIh3XP7yjc7ly4vpj06AkoBND36SodPs5qfhb8rHc=
github.com/splitio/go-split-commons/v6 v6.0.2-0.20241122192419-cc8d0413fa8e h1:0PMjUqkHtruM6arvxNbC3Yu6goqdkL/FuYeoWNmQ3K4=
github.com/splitio/go-split-commons/v6 v6.0.2-0.20241122192419-cc8d0413fa8e/go.mod h1:D/XIY/9Hmfk9ivWsRsJVp439kEdmHbzUi3PKzQQDOXY=
github.com/splitio/go-toolkit/v5 v5.4.0 h1:g5WFpRhQomnXCmvfsNOWV4s5AuUrWIZ+amM68G8NBKM=
github.com/splitio/go-toolkit/v5 v5.4.0/go.mod h1:xYhUvV1gga9/1029Wbp5pjnR6Cy8nvBpjw99wAbsMko=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
Expand Down
8 changes: 6 additions & 2 deletions splitio/proxy/caching/mocks/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func (s *LargeSegmentStorageMock) Count() int {
func (s *LargeSegmentStorageMock) LargeSegmentsForUser(userKey string) []string {
return []string{}
}
func (s *LargeSegmentStorageMock) ContainsKey(name string, key string) (bool, error) {
func (s *LargeSegmentStorageMock) IsInLargeSegment(name string, key string) (bool, error) {
args := s.Called(name, key)
return args.Get(0).(bool), args.Error(1)
}
Expand All @@ -168,7 +168,11 @@ func (u *LargeSegmentUpdaterMock) SynchronizeLargeSegments() (map[string]*int64,
return args.Get(0).(map[string]*int64), args.Error(1)
}
func (u *LargeSegmentUpdaterMock) IsCached(name string) bool {
return false
return u.Called().Get(0).(bool)
}
func (u *LargeSegmentUpdaterMock) SynchronizeLargeSegmentUpdate(lsRFDResponseDTO *dtos.LargeSegmentRFDResponseDTO) (*int64, error) {
args := u.Called(lsRFDResponseDTO)
return args.Get(0).(*int64), args.Error(1)
}

// ---
Expand Down
9 changes: 9 additions & 0 deletions splitio/proxy/caching/workers.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,3 +214,12 @@ func (c *CacheAwareLargeSegmentSynchronizer) shouldEvictBySurrogate(name string,
func (c *CacheAwareLargeSegmentSynchronizer) IsCached(name string) bool {
return c.wrapped.IsCached(name)
}

func (c *CacheAwareLargeSegmentSynchronizer) SynchronizeLargeSegmentUpdate(lsRFDResponseDTO *dtos.LargeSegmentRFDResponseDTO) (*int64, error) {
previous := c.largeSegmentStorage.ChangeNumber(lsRFDResponseDTO.Name)
newCN, err := c.wrapped.SynchronizeLargeSegmentUpdate(lsRFDResponseDTO)

c.shouldEvictBySurrogate(lsRFDResponseDTO.Name, previous, *newCN)

return newCN, err
}

0 comments on commit a7e24cf

Please sign in to comment.