Skip to content

Commit

Permalink
Upgrade dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergio Andres Virviescas Santana committed Jan 4, 2021
1 parent f6b0282 commit 790124e
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 21 deletions.
4 changes: 2 additions & 2 deletions config.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package session

import (
"github.com/savsgio/gotils"
"github.com/savsgio/gotils/bytes"
"github.com/valyala/fasthttp"
)

Expand Down Expand Up @@ -30,7 +30,7 @@ func NewDefaultConfig() Config {
}

func (c *Config) defaultSessionIDGenerator() []byte {
return gotils.RandBytes(make([]byte, c.cookieLen))
return bytes.Rand(make([]byte, c.cookieLen))
}

func (c *Config) defaultIsSecureFunc(ctx *fasthttp.RequestCtx) bool {
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ require (
github.com/go-sql-driver/mysql v1.5.0
github.com/lib/pq v1.9.0
github.com/mattn/go-sqlite3 v1.14.6
github.com/savsgio/dictpool v0.0.0-20201211144637-d4adfdb24374
github.com/savsgio/gotils v0.0.0-20200909101946-939aa3fc74fb
github.com/savsgio/dictpool v0.0.0-20210104112344-3a2df09158c0
github.com/savsgio/gotils v0.0.0-20210104112019-96a5e1e9898f
github.com/valyala/bytebufferpool v1.0.0
github.com/valyala/fasthttp v1.18.0
github.com/valyala/fasthttp v1.19.0
)
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ github.com/philhofer/fwd v1.1.1 h1:GdGcTjf5RNAxwS4QLsiMzJYj5KEvPJD3Abr261yRQXQ=
github.com/philhofer/fwd v1.1.1/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/savsgio/dictpool v0.0.0-20201211144637-d4adfdb24374 h1:lTlFbJC3w11+2lMuxRKxd1JdOzEWbsIy2x/ooVvHRx8=
github.com/savsgio/dictpool v0.0.0-20201211144637-d4adfdb24374/go.mod h1:Py00ogKS911m5KWduT43fZrEmDoBdfrinOuRQID+Szg=
github.com/savsgio/gotils v0.0.0-20200909101946-939aa3fc74fb h1:XPJCVf85HPE2jMVEQ7QWrazaZo1lc94GbUWaQ8Yv5sM=
github.com/savsgio/gotils v0.0.0-20200909101946-939aa3fc74fb/go.mod h1:TWNAOTaVzGOXq8RbEvHnhzA/A2sLZzgn0m6URjnukY8=
github.com/savsgio/dictpool v0.0.0-20210104112344-3a2df09158c0 h1:jpmXPe3YADAMQ4d//5M9ySV7bjNM3+MHwK4QBvGar7M=
github.com/savsgio/dictpool v0.0.0-20210104112344-3a2df09158c0/go.mod h1:XYRjAhsLTa09pP7RJmkDvEthe6eVBSx1Cufu6GN+Q+c=
github.com/savsgio/gotils v0.0.0-20210104112019-96a5e1e9898f h1:MlVk9SWHScKX//xsHudKurgtyVOmD06TLYKnuTPNK4g=
github.com/savsgio/gotils v0.0.0-20210104112019-96a5e1e9898f/go.mod h1:TWNAOTaVzGOXq8RbEvHnhzA/A2sLZzgn0m6URjnukY8=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
Expand All @@ -61,8 +61,8 @@ github.com/tinylib/msgp v1.1.5/go.mod h1:eQsjooMTnV42mHu917E26IogZ2930nFyBQdofk1
github.com/ttacon/chalk v0.0.0-20160626202418-22c06c80ed31/go.mod h1:onvgF043R+lC5RZ8IT9rBXDaEDnpnw/Cl+HFiw+v/7Q=
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
github.com/valyala/fasthttp v1.18.0 h1:IV0DdMlatq9QO1Cr6wGJPVW1sV1Q8HvZXAIcjorylyM=
github.com/valyala/fasthttp v1.18.0/go.mod h1:jjraHZVbKOXftJfsOYoAjaeygpj5hr8ermTRJNroD7A=
github.com/valyala/fasthttp v1.19.0 h1:PfTS4PeH3xDr3WomrDS2ID8lU2GskK1xS3YG6gIpibU=
github.com/valyala/fasthttp v1.19.0/go.mod h1:jjraHZVbKOXftJfsOYoAjaeygpj5hr8ermTRJNroD7A=
github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a/go.mod h1:v3UYOV9WzVtRmSR+PDvWpU/qWl4Wa5LApYYX4ZtKbio=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
go.opentelemetry.io/otel v0.13.0 h1:2isEnyzjjJZq6r2EKMsFj4TxiQiexsM04AVhwbR/oBA=
Expand Down
12 changes: 6 additions & 6 deletions internal/sql/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"database/sql"
"time"

"github.com/savsgio/gotils"
"github.com/savsgio/gotils/strconv"
)

// NewProvider returns a new configured sql provider
Expand Down Expand Up @@ -69,7 +69,7 @@ func (p *Provider) Close() error {

// Get returns the data of the given session id
func (p *Provider) Get(id []byte) ([]byte, error) {
result := p.db.QueryRow(p.config.SQLGet, gotils.B2S(id))
result := p.db.QueryRow(p.config.SQLGet, strconv.B2S(id))

data := []byte("")

Expand All @@ -85,13 +85,13 @@ func (p *Provider) Get(id []byte) ([]byte, error) {
func (p *Provider) Save(id, data []byte, expiration time.Duration) error {
now := time.Now().UnixNano()

n, err := p.Exec(p.config.SQLSave, gotils.B2S(data), now, expiration.Nanoseconds(), gotils.B2S(id))
n, err := p.Exec(p.config.SQLSave, strconv.B2S(data), now, expiration.Nanoseconds(), strconv.B2S(id))
if err != nil {
return err
}

if n == 0 { // Not exist
_, err = p.Exec(p.config.SQLInsert, gotils.B2S(id), gotils.B2S(data), now, expiration.Nanoseconds())
_, err = p.Exec(p.config.SQLInsert, strconv.B2S(id), strconv.B2S(data), now, expiration.Nanoseconds())
if err != nil {
return err
}
Expand All @@ -105,13 +105,13 @@ func (p *Provider) Save(id, data []byte, expiration time.Duration) error {
func (p *Provider) Regenerate(id, newID []byte, expiration time.Duration) error {
now := time.Now().UnixNano()

n, err := p.Exec(p.config.SQLRegenerate, gotils.B2S(newID), now, expiration.Nanoseconds(), gotils.B2S(id))
n, err := p.Exec(p.config.SQLRegenerate, strconv.B2S(newID), now, expiration.Nanoseconds(), strconv.B2S(id))
if err != nil {
return err
}

if n == 0 { // Not exist
_, err = p.Exec(p.config.SQLInsert, gotils.B2S(newID), "", now, expiration.Nanoseconds())
_, err = p.Exec(p.config.SQLInsert, strconv.B2S(newID), "", now, expiration.Nanoseconds())
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions providers/memory/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"time"

"github.com/fasthttp/session/v2"
"github.com/savsgio/gotils"
"github.com/savsgio/gotils/strconv"
)

var itemPool = &sync.Pool{
Expand Down Expand Up @@ -111,7 +111,7 @@ func (p *Provider) GC() error {
}

if now >= (item.lastActiveTime + item.expiration.Nanoseconds()) {
p.Destroy(gotils.S2B(kv.Key))
p.Destroy(strconv.S2B(kv.Key))
}
}

Expand Down
4 changes: 2 additions & 2 deletions store.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import (
"fmt"
"time"

"github.com/savsgio/gotils"
"github.com/savsgio/gotils/bytes"
)

var expirationAttrKey = fmt.Sprintf("__store:expiration:%s__", gotils.RandBytes(make([]byte, 5)))
var expirationAttrKey = fmt.Sprintf("__store:expiration:%s__", bytes.Rand(make([]byte, 5)))

// NewStore returns a new empty store
func NewStore() *Store {
Expand Down

0 comments on commit 790124e

Please sign in to comment.