Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

redis client to v9 #611

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
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 cmd/chirpstack-network-server/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"strings"
"time"

"github.com/go-redis/redis/v8"
"github.com/mitchellh/mapstructure"
"github.com/redis/go-redis/v9"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/spf13/viper"
Expand Down
7 changes: 6 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ module github.com/brocaar/chirpstack-network-server/v3

go 1.17

// TODO: remove before merging
replace github.com/brocaar/lorawan => github.com/nwest1/lorawan v0.0.0-20240129183920-3a95d67cf5a9

require (
cloud.google.com/go/pubsub v1.3.1
github.com/Azure/azure-amqp-common-go v1.1.4
Expand All @@ -24,6 +27,7 @@ require (
github.com/mitchellh/mapstructure v1.1.2
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.14.0
github.com/redis/go-redis/v9 v9.0.3
github.com/sirupsen/logrus v1.7.0
github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a
github.com/spf13/cobra v0.0.5
Expand Down Expand Up @@ -55,7 +59,7 @@ require (
github.com/caarlos0/ctrlc v1.0.0 // indirect
github.com/campoy/unique v0.0.0-20180121183637-88950e537e7e // indirect
github.com/census-instrumentation/opencensus-proto v0.2.1 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/devigned/tab v0.1.1 // indirect
github.com/dgrijalva/jwt-go v3.2.0+incompatible // indirect
Expand Down Expand Up @@ -118,3 +122,4 @@ require (
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect
)

10 changes: 9 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ github.com/brocaar/chirpstack-api/go/v3 v3.12.5 h1:sLV+zSZLUPnNCo2mf+gsw0ektbSiS
github.com/brocaar/chirpstack-api/go/v3 v3.12.5/go.mod h1:v8AWP19nOJK4rwJsr1+weDfpUc4UNLbRh8Eygn4Oh00=
github.com/brocaar/lorawan v0.0.0-20220715134808-3b283dda1534 h1:vqq/suBJc3KWCDOfJFEMx3t83cBdjldR5yLGps/3DWo=
github.com/brocaar/lorawan v0.0.0-20220715134808-3b283dda1534/go.mod h1:Vlf3gOwizqX4y3snWe/i2EqRT83HvYuwBjRu39PevW0=
github.com/bsm/ginkgo/v2 v2.7.0 h1:ItPMPH90RbmZJt5GtkcNvIRuGEdwlBItdNVoyzaNQao=
github.com/bsm/ginkgo/v2 v2.7.0/go.mod h1:AiKlXPm7ItEHNc/2+OkrNG4E0ITzojb9/xWzvQ9XZ9w=
github.com/bsm/gomega v1.26.0 h1:LhQm+AFcgV2M0WyKroMASzAzCAJVpAxQXv4SaI9a69Y=
github.com/bsm/gomega v1.26.0/go.mod h1:JyEr/xRbxbtgWNi8tIEVPUYZ5Dzef52k01W3YH0H+O0=
github.com/caarlos0/ctrlc v1.0.0 h1:2DtF8GSIcajgffDFJzyG15vO+1PuBWOMUdFut7NnXhw=
github.com/caarlos0/ctrlc v1.0.0/go.mod h1:CdXpj4rmq0q/1Eb44M9zi2nKB0QraNKuRGYGrrHhcQw=
github.com/campoy/unique v0.0.0-20180121183637-88950e537e7e h1:V9a67dfYqPLAvzk5hMQOXYJlZ4SLIXgyKIE+ZiHzgGQ=
Expand All @@ -103,8 +107,9 @@ github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA
github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko=
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE=
github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
Expand Down Expand Up @@ -432,6 +437,7 @@ github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRW
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/nakagami/firebirdsql v0.0.0-20190310045651-3c02a58cfed8/go.mod h1:86wM1zFnC6/uDBfZGNwB65O+pR2OFi5q/YQaEUid1qA=
github.com/neo4j/neo4j-go-driver v1.8.1-0.20200803113522-b626aa943eba/go.mod h1:ncO5VaFWh0Nrt+4KT4mOZboaczBZcLuHrG+/sUeP8gI=
github.com/nwest1/lorawan v0.0.0-20240129183920-3a95d67cf5a9/go.mod h1:oKMzRe/ekBzG+WYHtRqqAQMpGOgUXAYAWC899cJjvew=
github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78=
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw=
Expand Down Expand Up @@ -492,6 +498,8 @@ github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1
github.com/prometheus/procfs v0.8.0 h1:ODq8ZFEaYeCaZOJlZZdJA2AbQR98dSHSM1KW/You5mo=
github.com/prometheus/procfs v0.8.0/go.mod h1:z7EfXMXOkbkqb9IINtpCn86r/to3BnA0uaxHdg830/4=
github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
github.com/redis/go-redis/v9 v9.0.3 h1:+7mmR26M0IvyLxGZUHxu4GiBkJkVDid0Un+j4ScYu4k=
github.com/redis/go-redis/v9 v9.0.3/go.mod h1:WqMKv5vnQbRuZstUwxQI195wHy+t4PuXDOjzMvcuQHk=
github.com/remyoudompheng/bigfft v0.0.0-20190728182440-6a916e37a237/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
Expand Down
2 changes: 1 addition & 1 deletion internal/backend/joinserver/joinserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"strings"
"time"

"github.com/go-redis/redis/v8"
"github.com/pkg/errors"
"github.com/redis/go-redis/v9"
log "github.com/sirupsen/logrus"

"github.com/brocaar/chirpstack-network-server/v3/internal/config"
Expand Down
22 changes: 13 additions & 9 deletions internal/framelog/framelog.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package framelog
import (
"context"

"github.com/go-redis/redis/v8"
proto "github.com/golang/protobuf/proto"
"github.com/golang/protobuf/ptypes"
"github.com/pkg/errors"
"github.com/redis/go-redis/v9"

"github.com/brocaar/chirpstack-api/go/v3/gw"
"github.com/brocaar/chirpstack-api/go/v3/ns"
Expand Down Expand Up @@ -75,8 +75,9 @@ func LogUplinkFrameForGateways(ctx context.Context, frame ns.UplinkFrameLog) err
if conf.Monitoring.GatewayFrameLogMaxHistory > 0 {
key := storage.GetRedisKey(globalGatewayFrameStreamKey)
if err := storage.RedisClient().XAdd(ctx, &redis.XAddArgs{
Stream: key,
MaxLenApprox: conf.Monitoring.GatewayFrameLogMaxHistory,
Stream: key,
MaxLen: conf.Monitoring.GatewayFrameLogMaxHistory,
Approx: true,
Values: map[string]interface{}{
"up": b,
},
Expand Down Expand Up @@ -127,8 +128,9 @@ func LogDownlinkFrameForGateway(ctx context.Context, frame ns.DownlinkFrameLog)
if conf.Monitoring.GatewayFrameLogMaxHistory > 0 {
key := storage.GetRedisKey(globalGatewayFrameStreamKey)
if err := storage.RedisClient().XAdd(ctx, &redis.XAddArgs{
Stream: key,
MaxLenApprox: conf.Monitoring.GatewayFrameLogMaxHistory,
Stream: key,
MaxLen: conf.Monitoring.GatewayFrameLogMaxHistory,
Approx: true,
Values: map[string]interface{}{
"down": b,
},
Expand Down Expand Up @@ -176,8 +178,9 @@ func LogUplinkFrameForDevEUI(ctx context.Context, devEUI lorawan.EUI64, frame ns
if conf.Monitoring.DeviceFrameLogMaxHistory > 0 {
key := storage.GetRedisKey(globalDeviceFrameStreamKey)
if err := storage.RedisClient().XAdd(ctx, &redis.XAddArgs{
Stream: key,
MaxLenApprox: conf.Monitoring.DeviceFrameLogMaxHistory,
Stream: key,
MaxLen: conf.Monitoring.DeviceFrameLogMaxHistory,
Approx: true,
Values: map[string]interface{}{
"up": b,
},
Expand Down Expand Up @@ -225,8 +228,9 @@ func LogDownlinkFrameForDevEUI(ctx context.Context, devEUI lorawan.EUI64, frame
if conf.Monitoring.DeviceFrameLogMaxHistory > 0 {
key := storage.GetRedisKey(globalDeviceFrameStreamKey)
if err := storage.RedisClient().XAdd(ctx, &redis.XAddArgs{
Stream: key,
MaxLenApprox: conf.Monitoring.DeviceFrameLogMaxHistory,
Stream: key,
MaxLen: conf.Monitoring.DeviceFrameLogMaxHistory,
Approx: true,
Values: map[string]interface{}{
"down": b,
},
Expand Down
2 changes: 1 addition & 1 deletion internal/framelog/framelog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"testing"
"time"

"github.com/go-redis/redis/v8"
"github.com/golang/protobuf/proto"
"github.com/redis/go-redis/v9"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"

Expand Down
2 changes: 1 addition & 1 deletion internal/roaming/roaming.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"fmt"
"time"

"github.com/go-redis/redis/v8"
"github.com/pkg/errors"
"github.com/redis/go-redis/v9"
log "github.com/sirupsen/logrus"

"github.com/brocaar/chirpstack-network-server/v3/internal/config"
Expand Down
2 changes: 1 addition & 1 deletion internal/storage/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"database/sql"
"time"

"github.com/go-redis/redis/v8"
"github.com/jmoiron/sqlx"
"github.com/redis/go-redis/v9"

// register postgresql driver
_ "github.com/lib/pq"
Expand Down
2 changes: 1 addition & 1 deletion internal/storage/device_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import (
"time"

"github.com/brocaar/chirpstack-network-server/v3/internal/logging"
"github.com/go-redis/redis/v8"
"github.com/gofrs/uuid"
"github.com/jmoiron/sqlx"
"github.com/lib/pq"
"github.com/pkg/errors"
"github.com/redis/go-redis/v9"
log "github.com/sirupsen/logrus"
)

Expand Down
18 changes: 9 additions & 9 deletions internal/storage/device_session.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import (
"strings"
"time"

"github.com/go-redis/redis/v8"
"github.com/gofrs/uuid"
proto "github.com/golang/protobuf/proto"
"github.com/pkg/errors"
"github.com/redis/go-redis/v9"
log "github.com/sirupsen/logrus"

"github.com/brocaar/chirpstack-api/go/v3/common"
Expand Down Expand Up @@ -299,14 +299,14 @@ func GetRandomDevAddr(netID lorawan.NetID) (lorawan.DevAddr, error) {
// GetFullFCntUp returns the full 32bit frame-counter, given the fCntUp which
// has been truncated to the last 16 LSB.
// Notes:
// * After a succesful validation of the FCntUp and the MIC, don't forget
// to synchronize the device FCntUp with the packet FCnt.
// * In case of a frame-counter rollover, the returned values will be less
// than the given DeviceSession FCntUp. This must be validated outside this
// function!
// * In case of a re-transmission, the returned frame-counter equals
// DeviceSession.FCntUp - 1, as the FCntUp value holds the next expected
// frame-counter, not the FCntUp which was last seen.
// - After a succesful validation of the FCntUp and the MIC, don't forget
// to synchronize the device FCntUp with the packet FCnt.
// - In case of a frame-counter rollover, the returned values will be less
// than the given DeviceSession FCntUp. This must be validated outside this
// function!
// - In case of a re-transmission, the returned frame-counter equals
// DeviceSession.FCntUp - 1, as the FCntUp value holds the next expected
// frame-counter, not the FCntUp which was last seen.
func GetFullFCntUp(nextExpectedFullFCnt, truncatedFCntUp uint32) uint32 {
// Handle re-transmission.
// Note: the s.FCntUp value holds the next expected uplink frame-counter,
Expand Down
2 changes: 1 addition & 1 deletion internal/storage/downlink_frame.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (
"context"
"time"

"github.com/go-redis/redis/v8"
proto "github.com/golang/protobuf/proto"
"github.com/pkg/errors"
"github.com/redis/go-redis/v9"
log "github.com/sirupsen/logrus"

"github.com/brocaar/chirpstack-network-server/v3/internal/logging"
Expand Down
2 changes: 1 addition & 1 deletion internal/storage/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import (
"strconv"
"time"

"github.com/go-redis/redis/v8"
"github.com/gofrs/uuid"
"github.com/jmoiron/sqlx"
"github.com/lib/pq"
"github.com/pkg/errors"
"github.com/redis/go-redis/v9"
log "github.com/sirupsen/logrus"

"github.com/brocaar/chirpstack-network-server/v3/internal/logging"
Expand Down
2 changes: 1 addition & 1 deletion internal/storage/mac_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"context"
"encoding/gob"

"github.com/go-redis/redis/v8"
"github.com/pkg/errors"
"github.com/redis/go-redis/v9"
log "github.com/sirupsen/logrus"

"github.com/brocaar/chirpstack-network-server/v3/internal/logging"
Expand Down
4 changes: 2 additions & 2 deletions internal/storage/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"strconv"
"time"

"github.com/go-redis/redis/v8"
"github.com/pkg/errors"
"github.com/redis/go-redis/v9"
)

// AggregationInterval defines the aggregation type.
Expand Down Expand Up @@ -107,7 +107,7 @@ func GetMetrics(ctx context.Context, agg AggregationInterval, name string, start
}

pipe := RedisClient().Pipeline()
var vals []*redis.StringStringMapCmd
var vals []*redis.MapStringStringCmd
for _, k := range keys {
vals = append(vals, pipe.HGetAll(ctx, k))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"strings"
"time"

"github.com/go-redis/redis/v8"
"github.com/pkg/errors"
"github.com/redis/go-redis/v9"
log "github.com/sirupsen/logrus"
)

Expand Down
2 changes: 1 addition & 1 deletion internal/storage/passive_roaming.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import (
"fmt"
"time"

"github.com/go-redis/redis/v8"
"github.com/gofrs/uuid"
"github.com/golang/protobuf/proto"
"github.com/golang/protobuf/ptypes"
"github.com/pkg/errors"
"github.com/redis/go-redis/v9"
log "github.com/sirupsen/logrus"

"github.com/brocaar/chirpstack-network-server/v3/internal/logging"
Expand Down
2 changes: 1 addition & 1 deletion internal/storage/service_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import (
"encoding/gob"
"time"

"github.com/go-redis/redis/v8"
"github.com/gofrs/uuid"
"github.com/jmoiron/sqlx"
"github.com/pkg/errors"
"github.com/redis/go-redis/v9"
log "github.com/sirupsen/logrus"

"github.com/brocaar/chirpstack-network-server/v3/internal/logging"
Expand Down
3 changes: 2 additions & 1 deletion internal/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import (
"net/http"
"time"

"github.com/go-redis/redis/v8"
"github.com/golang-migrate/migrate/v4"
"github.com/golang-migrate/migrate/v4/database/postgres"
"github.com/golang-migrate/migrate/v4/source/httpfs"
"github.com/jmoiron/sqlx"
"github.com/pkg/errors"
"github.com/redis/go-redis/v9"
log "github.com/sirupsen/logrus"

"github.com/brocaar/chirpstack-network-server/v3/internal/config"
Expand All @@ -21,6 +21,7 @@ import (
)

// Migrations
//
//go:embed migrations/*
var migrations embed.FS

Expand Down