forked from distributedio/titan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
util.go
43 lines (36 loc) · 1.37 KB
/
util.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package titan
import (
"fmt"
"sync/atomic"
"github.com/twinj/uuid"
"github.com/meitu/titan/context"
"go.uber.org/zap"
)
func logVersionInfo() {
zap.L().Info("Welcome to Titan.")
zap.L().Info("Server info", zap.String("Release Version", context.ReleaseVersion))
zap.L().Info("Server info", zap.String("Git Commit Hash", context.GitHash))
zap.L().Info("Server info", zap.String("Git Commit Log", context.GitLog))
zap.L().Info("Server info", zap.String("Git Branch", context.GitBranch))
zap.L().Info("Server info", zap.String("UTC Build Time", context.BuildTS))
zap.L().Info("Server info", zap.String("Golang compiler Version", context.GolangVersion))
}
// PrintVersionInfo prints the server version info
func PrintVersionInfo() {
fmt.Println("Welcome to Titan.")
fmt.Println("Release Version: ", context.ReleaseVersion)
fmt.Println("Git Commit Hash: ", context.GitHash)
fmt.Println("Git Commit Log: ", context.GitLog)
fmt.Println("Git Branch: ", context.GitBranch)
fmt.Println("UTC Build Time: ", context.BuildTS)
fmt.Println("Golang compiler Version: ", context.GolangVersion)
}
//GetClientID starts with 1 and allocates clientID incrementally
func GetClientID() func() int64 {
var id int64 = 1
return func() int64 {
return atomic.AddInt64(&id, 1)
}
}
//GenerateTraceID grenerates a traceid for once a request
func GenerateTraceID() string { return uuid.NewV4().String() }