Skip to content

Commit

Permalink
chore(repositories): use gonanoid instead of uuid for payload IDs
Browse files Browse the repository at this point in the history
  • Loading branch information
Icikowski committed Dec 30, 2022
1 parent 10b19a3 commit 9b46cde
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
10 changes: 5 additions & 5 deletions src/data/payloads.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"sync"
"time"

"github.com/google/uuid"
gonanoid "github.com/matoous/go-nanoid/v2"
"github.com/pkg/errors"
"github.com/rs/zerolog"
)
Expand Down Expand Up @@ -167,9 +167,9 @@ func (s *PayloadsStore) Count() int {
return len(s.content)
}

func getRandomUUID() string {
rawId, _ := uuid.NewRandom()
return rawId.String()
func getUniqueID() string {
id, _ := gonanoid.New()
return id
}

func (s *PayloadsStore) createTempFile(src io.ReadCloser) (string, int64, error) {
Expand All @@ -192,7 +192,7 @@ func (s *PayloadsStore) createTempFile(src io.ReadCloser) (string, int64, error)

// InsertFile implements FileStore
func (s *PayloadsStore) InsertFile(name string, src io.ReadCloser) (string, error) {
id := getRandomUUID()
id := getUniqueID()

filename, size, err := s.createTempFile(src)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion src/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/Icikowski/kubeprobes v1.2.0
github.com/caarlos0/env/v6 v6.10.1
github.com/go-chi/chi/v5 v5.0.7
github.com/google/uuid v1.3.0
github.com/matoous/go-nanoid/v2 v2.0.0
github.com/pkg/errors v0.9.1
github.com/rs/zerolog v1.28.0
github.com/stretchr/testify v1.8.1
Expand Down
5 changes: 3 additions & 2 deletions src/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
github.com/go-chi/chi/v5 v5.0.7 h1:rDTPXLDHGATaeHvVlLcR4Qe0zftYethFucbjVQ1PxU8=
github.com/go-chi/chi/v5 v5.0.7/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8=
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/matoous/go-nanoid v1.5.0/go.mod h1:zyD2a71IubI24efhpvkJz+ZwfwagzgSO6UNiFsZKN7U=
github.com/matoous/go-nanoid/v2 v2.0.0 h1:d19kur2QuLeHmJBkvYkFdhFBzLoo1XVm2GgTpL+9Tj0=
github.com/matoous/go-nanoid/v2 v2.0.0/go.mod h1:FtS4aGPVfEkxKxhdWPAspZpZSh1cOjtM7Ej/So3hR0g=
github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
Expand Down

0 comments on commit 9b46cde

Please sign in to comment.