Skip to content

Commit

Permalink
upgrades, added lll linter
Browse files Browse the repository at this point in the history
  • Loading branch information
bogcon committed Nov 2, 2022
1 parent 90ef167 commit daa68f4
Show file tree
Hide file tree
Showing 14 changed files with 26 additions and 14 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
fail-fast: false
matrix:
go-version: [1.17.x, 1.18.x, 1.19.x]
go-version: [1.18.x, 1.19.x]
platform: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.platform }}

Expand Down Expand Up @@ -51,7 +51,7 @@ jobs:
strategy:
fail-fast: false
matrix:
go-version: [1.17.x, 1.18.x, 1.19.x]
go-version: [1.18.x, 1.19.x]

services:
redis6:
Expand All @@ -65,7 +65,7 @@ jobs:
- 6379:6379

redis7:
image: redis:7.0.4
image: redis:7.0.5
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
Expand Down
1 change: 1 addition & 0 deletions .golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ linters:
- nlreturn
- noctx
- whitespace
- lll

issues:
exclude-use-default: false
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
LINTER_VERSION=v1.49.0
LINTER_VERSION=v1.50.1
LINTER=./bin/golangci-lint
ifeq ($(OS),Windows_NT)
LINTER=./bin/golangci-lint.exe
Expand Down
2 changes: 1 addition & 1 deletion build/Dockerfile.benchmark.local
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.19.1-alpine3.16
FROM golang:1.19.3-alpine3.16

LABEL maintainer="Bogdan Constantinescu"
LABEL description="Benchmark Runner for XCache"
Expand Down
2 changes: 1 addition & 1 deletion build/Dockerfile.test.local
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.19.1-alpine3.16
FROM golang:1.19.3-alpine3.16

LABEL maintainer="Bogdan Constantinescu"
LABEL description="Test Runner for XCache"
Expand Down
6 changes: 4 additions & 2 deletions memory_xconf_adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ const (
// An observer is registered to xconf.DefaultConfig (which knows to reload configuration).
// In case "xcache.memory.memsizebytes" config is changed, the Memory is reinitialized with the new memory size,
// and all items from old freecache instance are copied to the new one. Note: host machine/container needs to have
// additional to current occupied memory, the new memory size available (until old memory is garbage collected, old memory size is still occupied).
// additional to current occupied memory, the new memory size available (until old memory is garbage collected,
// old memory size is still occupied).
func NewMemoryWithConfig(config xconf.Config) *Memory {
mem := config.Get(MemoryCfgKeyMemorySize, memoryCfgDefValueMemorySize).(int)

Expand Down Expand Up @@ -63,7 +64,8 @@ func (cache *Memory) onConfigChange(config xconf.Config, changedKeys ...string)
cache.mu.Lock()
if memSize != int(cache.memSize) {
// note 1: stats will be reset on the new client.
// note 2: during this code execution memory occupied will be oldMemorySize + newMemorySize so machine needs to have to this memory available.
// note 2: during this code execution memory occupied will be oldMemorySize + newMemorySize,
// so machine needs to have to this memory available.
// note 3: not tested performance if a large number of keys needs to be copied.

newClient := freecache.NewCache(memSize)
Expand Down
5 changes: 4 additions & 1 deletion multi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ func TestMulti_Save_Load(t *testing.T) {

t.Run("success - load 1", testMultiLoadReturnsValueFoundInFirstCache)
t.Run("success - load 2", testMultiLoadReturnsValueFoundInSecondCache)
t.Run("success - load 2, err is ignored for cache 1", testMultiLoadReturnsValueFoundInSecondCacheEvenIfFirstCacheLoadFailed)
t.Run(
"success - load 2, err is ignored for cache 1",
testMultiLoadReturnsValueFoundInSecondCacheEvenIfFirstCacheLoadFailed,
)
t.Run("error all - load", testMultiLoadAllCachesReturnErr)
t.Run("error not found - load", testMultiLoadReturnsNotFoundErr)
}
Expand Down
3 changes: 2 additions & 1 deletion redis6_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ func ExampleRedis6_withXConf() {
// From this point forward you can do whatever you want with the cache.
// Any config that gets changed, cache will reconfigure itself in a time up to reload interval (5 mins here)
// without the need of restarting/redeploying our application.
// For example, let's assume we notice a lot of timeout errors, until we figure it out what's happening with our Redis server,
// For example, let's assume we notice a lot of timeout errors,
// until we figure it out what's happening with our Redis server,
// we can increase read/write timeouts.
}
3 changes: 2 additions & 1 deletion redis7_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ func ExampleRedis7_withXConf() {
// From this point forward you can do whatever you want with the cache.
// Any config that gets changed, cache will reconfigure itself in a time up to reload interval (5 mins here)
// without the need of restarting/redeploying our application.
// For example, let's assume we notice a lot of timeout errors, until we figure it out what's happening with our Redis server,
// For example, let's assume we notice a lot of timeout errors,
// until we figure it out what's happening with our Redis server,
// we can increase read/write timeouts.
}
3 changes: 2 additions & 1 deletion redis_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import (
"time"
)

// Note: the difference between Redis6 and Redis7, in implementation, consists of using a different version of go-redis client.
// Note: the difference between Redis6 and Redis7, in implementation,
// consists of using a different version of go-redis client.

// redisTTLNoExpire is Redis TTL command reply value for a key with no expiration.
const redisTTLNoExpire = -1
Expand Down
2 changes: 1 addition & 1 deletion scripts/test_local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ CROSS_SIGN="[\xE2\x9D\x8C]"
REDIS_VERSIONS=( 6 7 )

DOCKER_REDIS6_IMAGE_VER=redis:6.2.7-alpine3.16
DOCKER_REDIS7_IMAGE_VER=redis:7.0.4-alpine3.16
DOCKER_REDIS7_IMAGE_VER=redis:7.0.5-alpine3.16
DOCKER_TEST_RUNNER_IMAGE_NAME=xcache-${RUN}-runner
DOCKER_NETWORK=xcache-network
if [ "$REDIS_SETUP" == "cluster" ]; then
Expand Down
1 change: 1 addition & 0 deletions stats_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"github.com/actforgood/xcache"
)

//nolint:lll
func TestStats_String(t *testing.T) {
t.Parallel()

Expand Down
1 change: 1 addition & 0 deletions xlog_adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ func NewRedisXLogger(logger xlog.Logger) RedisXLogger {
//
// Method categorizes the message as error/info based on presence of some words
// like "failed"/"error".
// nolint:lll
func (l RedisXLogger) Printf(_ context.Context, format string, v ...interface{}) {
msg := fmt.Sprintf(format, v...)
if strings.Contains(msg, "failed") || strings.Contains(msg, "error") {
Expand Down
3 changes: 2 additions & 1 deletion xlog_adapter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ func ExampleRedisXLogger() {
logger := xlog.NewSyncLogger(os.Stdout, xlog.SyncLoggerWithOptions(loggerOpts))
// set the xlog.Logger Redis adapter
redisLogger := xcache.NewRedisXLogger(logger)
xcache.SetRedis6Logger(redisLogger) // or xcache.SetRedis7Logger(redisLogger), depending which ver. of Redis you're using.
xcache.SetRedis6Logger(redisLogger) // or xcache.SetRedis7Logger(redisLogger),
// depending which ver. of Redis you're using.

// somewhere in your shutdown process ...
_ = logger.Close()
Expand Down

0 comments on commit daa68f4

Please sign in to comment.