Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-pages.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/gitlab.com/gitlab-org/labkit/correlation/generator.go')
-rw-r--r--vendor/gitlab.com/gitlab-org/labkit/correlation/generator.go44
1 files changed, 0 insertions, 44 deletions
diff --git a/vendor/gitlab.com/gitlab-org/labkit/correlation/generator.go b/vendor/gitlab.com/gitlab-org/labkit/correlation/generator.go
deleted file mode 100644
index 30ab93a2..00000000
--- a/vendor/gitlab.com/gitlab-org/labkit/correlation/generator.go
+++ /dev/null
@@ -1,44 +0,0 @@
-package correlation
-
-import (
- "crypto/rand"
- "fmt"
- "log"
- "math"
- "math/big"
- "net/http"
- "time"
-)
-
-var (
- randMax = big.NewInt(math.MaxInt64)
- randSource = rand.Reader
-)
-
-// generateRandomCorrelationID will attempt to generate a correlationid randomly
-// or raise an error
-func generateRandomCorrelationID() (string, error) {
- id, err := rand.Int(randSource, randMax)
- if err != nil {
- return "", err
- }
- base62 := encodeReverseBase62(id.Int64())
-
- return base62, nil
-}
-
-func generatePseudorandomCorrelationID(req *http.Request) string {
- return fmt.Sprintf("E:%s:%s", req.RemoteAddr, encodeReverseBase62(time.Now().UnixNano()))
-}
-
-// generateRandomCorrelationID will attempt to generate a correlationid randomly
-// if this fails, will log a message and fallback to a pseudorandom approach
-func generateRandomCorrelationIDWithFallback(req *http.Request) string {
- correlationID, err := generateRandomCorrelationID()
- if err == nil {
- return correlationID
- }
-
- log.Printf("can't generate random correlation-id: %v", err)
- return generatePseudorandomCorrelationID(req)
-}