mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-19 09:14:27 +08:00
add comments, code refactor
This commit is contained in:
@@ -4,14 +4,17 @@ import (
|
||||
"github.com/mayswind/lab/pkg/settings"
|
||||
)
|
||||
|
||||
// RequestIdContainer contains the current request id generator
|
||||
type RequestIdContainer struct {
|
||||
Current RequestIdGenerator
|
||||
}
|
||||
|
||||
// Initialize a request id container singleton instance
|
||||
var (
|
||||
Container = &RequestIdContainer{}
|
||||
)
|
||||
|
||||
// InitializeRequestIdGenerator initialized the current request id generator according to the config
|
||||
func InitializeRequestIdGenerator(config *settings.Config) error {
|
||||
generator, err := NewDefaultRequestIdGenerator(config)
|
||||
|
||||
@@ -23,6 +26,7 @@ func InitializeRequestIdGenerator(config *settings.Config) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// GenerateRequestId returns a new request id by the current request id generator
|
||||
func (u *RequestIdContainer) GenerateRequestId(clientIpAddr string) string {
|
||||
return u.Current.GenerateRequestId(clientIpAddr)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user