Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ run:
# Define the Go version limit.
# Mainly related to generics support since go1.18.
# Default: use Go version from the go.mod file, fallback on the env var `GOVERSION`, fallback on 1.17
go: "1.26.0"
go: "1.26.1"

linters:
# Enable specific linter
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit/golangci-lint-hook
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ if [[ -f "${ROOT_DIR}/.project-settings.env" ]]; then
# shellcheck disable=SC1090
source "${ROOT_DIR}/.project-settings.env"
fi
GOLANGCI_LINT_VERSION="${GOLANGCI_LINT_VERSION:-v2.10.1}"
GOLANGCI_LINT_VERSION="${GOLANGCI_LINT_VERSION:-v2.11.3}"

# #######################################
# Install dependencies to run the pre-commit hook
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit/unit-test-hook
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ hook() {
local root_dir
root_dir=$(git rev-parse --show-toplevel)

local toolchain_version="1.26.0"
local toolchain_version="1.26.1"
if [[ -f "${root_dir}/.project-settings.env" ]]; then
# shellcheck disable=SC1090
source "${root_dir}/.project-settings.env"
Expand Down
6 changes: 3 additions & 3 deletions .project-settings.env
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
GOLANGCI_LINT_VERSION=v2.10.1
BUF_VERSION=v1.66.0
GO_VERSION=1.26.0
GOLANGCI_LINT_VERSION=v2.11.3
BUF_VERSION=v1.66.1
GO_VERSION=1.26.1
GCI_PREFIX=github.com/hyp3rd/hypercache
PROTO_ENABLED=false
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
include .project-settings.env

GOLANGCI_LINT_VERSION ?= v2.10.1
BUF_VERSION ?= v1.66.0
GO_VERSION ?= 1.26.0
GOLANGCI_LINT_VERSION ?= v2.11.3
BUF_VERSION ?= v1.66.1
GO_VERSION ?= 1.26.1
GCI_PREFIX ?= github.com/hyp3rd/hypercache
PROTO_ENABLED ?= true

Expand Down
18 changes: 9 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
module github.com/hyp3rd/hypercache

go 1.26.0
go 1.26.1

require (
github.com/cespare/xxhash/v2 v2.3.0
github.com/goccy/go-json v0.10.5
github.com/goccy/go-json v0.10.6
github.com/gofiber/fiber/v3 v3.1.0
github.com/hyp3rd/ewrap v1.3.7
github.com/hyp3rd/sectools v1.2.3
github.com/longbridgeapp/assert v1.1.0
github.com/redis/go-redis/v9 v9.18.0
github.com/shamaton/msgpack/v2 v2.4.0
github.com/ugorji/go/codec v1.3.1
go.opentelemetry.io/otel v1.40.0
go.opentelemetry.io/otel/metric v1.40.0
go.opentelemetry.io/otel/trace v1.40.0
go.opentelemetry.io/otel v1.42.0
go.opentelemetry.io/otel/metric v1.42.0
go.opentelemetry.io/otel/trace v1.42.0
)

require (
Expand All @@ -36,10 +36,10 @@ require (
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasthttp v1.69.0 // indirect
go.uber.org/atomic v1.11.0 // indirect
golang.org/x/crypto v0.48.0 // indirect
golang.org/x/net v0.51.0 // indirect
golang.org/x/sys v0.41.0 // indirect
golang.org/x/text v0.34.0 // indirect
golang.org/x/crypto v0.49.0 // indirect
golang.org/x/net v0.52.0 // indirect
golang.org/x/sys v0.42.0 // indirect
golang.org/x/text v0.35.0 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
32 changes: 16 additions & 16 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=
github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
github.com/goccy/go-json v0.10.5 h1:Fq85nIqj+gXn/S5ahsiTlK3TmC85qgirsdTP/+DeaC4=
github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
github.com/goccy/go-json v0.10.6 h1:p8HrPJzOakx/mn/bQtjgNjdTcN+/S6FcG2CTtQOrHVU=
github.com/goccy/go-json v0.10.6/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
github.com/gofiber/fiber/v3 v3.1.0 h1:1p4I820pIa+FGxfwWuQZ5rAyX0WlGZbGT6Hnuxt6hKY=
github.com/gofiber/fiber/v3 v3.1.0/go.mod h1:n2nYQovvL9z3Too/FGOfgtERjW3GQcAUqgfoezGBZdU=
github.com/gofiber/schema v1.7.0 h1:yNM+FNRZjyYEli9Ey0AXRBrAY9jTnb+kmGs3lJGPvKg=
Expand Down Expand Up @@ -84,23 +84,23 @@ github.com/zeebo/xxh3 v1.0.2 h1:xZmwmqxHZA8AI603jOQ0tMqmBr9lPeFwGg6d+xy9DC0=
github.com/zeebo/xxh3 v1.0.2/go.mod h1:5NWz9Sef7zIDm2JHfFlcQvNekmcEl9ekUZQQKCYaDcA=
go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64=
go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y=
go.opentelemetry.io/otel v1.40.0 h1:oA5YeOcpRTXq6NN7frwmwFR0Cn3RhTVZvXsP4duvCms=
go.opentelemetry.io/otel v1.40.0/go.mod h1:IMb+uXZUKkMXdPddhwAHm6UfOwJyh4ct1ybIlV14J0g=
go.opentelemetry.io/otel/metric v1.40.0 h1:rcZe317KPftE2rstWIBitCdVp89A2HqjkxR3c11+p9g=
go.opentelemetry.io/otel/metric v1.40.0/go.mod h1:ib/crwQH7N3r5kfiBZQbwrTge743UDc7DTFVZrrXnqc=
go.opentelemetry.io/otel/trace v1.40.0 h1:WA4etStDttCSYuhwvEa8OP8I5EWu24lkOzp+ZYblVjw=
go.opentelemetry.io/otel/trace v1.40.0/go.mod h1:zeAhriXecNGP/s2SEG3+Y8X9ujcJOTqQ5RgdEJcawiA=
go.opentelemetry.io/otel v1.42.0 h1:lSQGzTgVR3+sgJDAU/7/ZMjN9Z+vUip7leaqBKy4sho=
go.opentelemetry.io/otel v1.42.0/go.mod h1:lJNsdRMxCUIWuMlVJWzecSMuNjE7dOYyWlqOXWkdqCc=
go.opentelemetry.io/otel/metric v1.42.0 h1:2jXG+3oZLNXEPfNmnpxKDeZsFI5o4J+nz6xUlaFdF/4=
go.opentelemetry.io/otel/metric v1.42.0/go.mod h1:RlUN/7vTU7Ao/diDkEpQpnz3/92J9ko05BIwxYa2SSI=
go.opentelemetry.io/otel/trace v1.42.0 h1:OUCgIPt+mzOnaUTpOQcBiM/PLQ/Op7oq6g4LenLmOYY=
go.opentelemetry.io/otel/trace v1.42.0/go.mod h1:f3K9S+IFqnumBkKhRJMeaZeNk9epyhnCmQh/EysQCdc=
go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE=
go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0=
golang.org/x/crypto v0.48.0 h1:/VRzVqiRSggnhY7gNRxPauEQ5Drw9haKdM0jqfcCFts=
golang.org/x/crypto v0.48.0/go.mod h1:r0kV5h3qnFPlQnBSrULhlsRfryS2pmewsg+XfMgkVos=
golang.org/x/net v0.51.0 h1:94R/GTO7mt3/4wIKpcR5gkGmRLOuE/2hNGeWq/GBIFo=
golang.org/x/net v0.51.0/go.mod h1:aamm+2QF5ogm02fjy5Bb7CQ0WMt1/WVM7FtyaTLlA9Y=
golang.org/x/crypto v0.49.0 h1:+Ng2ULVvLHnJ/ZFEq4KdcDd/cfjrrjjNSXNzxg0Y4U4=
golang.org/x/crypto v0.49.0/go.mod h1:ErX4dUh2UM+CFYiXZRTcMpEcN8b/1gxEuv3nODoYtCA=
golang.org/x/net v0.52.0 h1:He/TN1l0e4mmR3QqHMT2Xab3Aj3L9qjbhRm78/6jrW0=
golang.org/x/net v0.52.0/go.mod h1:R1MAz7uMZxVMualyPXb+VaqGSa3LIaUqk0eEt3w36Sw=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.41.0 h1:Ivj+2Cp/ylzLiEU89QhWblYnOE9zerudt9Ftecq2C6k=
golang.org/x/sys v0.41.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
golang.org/x/text v0.34.0 h1:oL/Qq0Kdaqxa1KbNeMKwQq0reLCCaFtqu2eNuSeNHbk=
golang.org/x/text v0.34.0/go.mod h1:homfLqTYRFyVYemLBFl5GgL/DWEiH5wcsQ5gSh1yziA=
golang.org/x/sys v0.42.0 h1:omrd2nAlyT5ESRdCLYdm3+fMfNFE/+Rf4bDIQImRJeo=
golang.org/x/sys v0.42.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
golang.org/x/text v0.35.0 h1:JOVx6vVDFokkpaq1AEptVzLTpDe9KGpj5tR4/X+ybL8=
golang.org/x/text v0.35.0/go.mod h1:khi/HExzZJ2pGnjenulevKNX1W67CUy0AsXcNubPGCA=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
Expand Down
13 changes: 12 additions & 1 deletion internal/cluster/ring.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cluster

import (
"fmt"
"slices"
"sort"
"sync"

Expand Down Expand Up @@ -77,7 +78,17 @@ func (r *Ring) Build(nodes []*Node) {
}
}

sort.Slice(vn, func(i, j int) bool { return vn[i].hash < vn[j].hash })
slices.SortFunc(vn, func(a, b vnode) int {
switch {
case a.hash < b.hash:
return -1
case a.hash > b.hash:
return 1
default:
return 0
}
})

r.mu.Lock()

r.vnodes = vn
Expand Down
11 changes: 8 additions & 3 deletions pkg/backend/dist_memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"hash/fnv"
"math/big"
"slices"
"sort"
"strings"
"sync"
"sync/atomic"
"time"
Expand Down Expand Up @@ -307,7 +307,9 @@ func (dm *DistMemory) BuildMerkleTree() *MerkleTree { //nolint:ireturn
return &MerkleTree{ChunkSize: chunkSize}
}

sort.Slice(entries, func(i, j int) bool { return entries[i].k < entries[j].k })
slices.SortFunc(entries, func(a, b merkleKV) int {
return strings.Compare(a.k, b.k)
})

hasher := sha256.New()
buf := make([]byte, merkleVersionBytes)
Expand Down Expand Up @@ -1182,7 +1184,10 @@ func (dm *DistMemory) RemovePeer(address string) { //nolint:ireturn
// sortedMerkleEntries returns merkle entries sorted by key.
func (dm *DistMemory) sortedMerkleEntries() []merkleKV { //nolint:ireturn
entries := dm.merkleEntries()
sort.Slice(entries, func(i, j int) bool { return entries[i].k < entries[j].k })

slices.SortFunc(entries, func(a, b merkleKV) int {
return strings.Compare(a.k, b.k)
})

return entries
}
Expand Down
13 changes: 11 additions & 2 deletions pkg/backend/filters.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package backend

import (
"sort"
"slices"

"github.com/hyp3rd/ewrap"

Expand Down Expand Up @@ -95,7 +95,16 @@ func (f sortByFilter) ApplyFilter(_ string, items []*cache.Item) ([]*cache.Item,
return nil, ewrap.Newf("invalid sort field: %s", f.field)
}

sort.Sort(sorter)
slices.SortFunc(items, func(a, b *cache.Item) int {
switch {
case sorter.less(a, b):
return -1
case sorter.less(b, a):
Comment on lines +98 to +102
return 1
default:
return 0
}
})

return items, nil
}
Expand Down
Loading