Documentation ¶
Index ¶
- func DeltaUint64(inpHID, nodeHID uint64) (uint64, error)
- func GetHashID(input string) (HID uint64)
- func GetStaticFileName(path string) (name string)
- func LoggerGenerator(formatter log.Formatter, output io.Writer, level log.Level) *log.Entry
- func ReadConfig(path string) (service []config.Service, err error)
- func StaticSuffixDetermine(name, rule string) (isStatic bool, err error)
- func StripURLPathPrefix(path, prefix string) (result string, ok bool)
- type LoggerConfig
- type Loggerable
- type MarshalUnmarshaler
- type Marshaler
- type Unmarshaler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeltaUint64 ¶
DeltaUint64 is a fuction return |i-j| on a ring mod 2^64 due to the type of i and j is unsined int64, so it's important to test whether one parameter is greater than the other one. 2.1 inpHID = 1, nodeHID = 5 => delta = 5 - 1 = 4 2.2 inpHID = 1, nodeHID = 2^64 - 2 => delta = 2^64 - 2 - 1 = 2^64 - 3 = 18446744073709551613 2.3. inpHID = 2^64 - 2, nodeHID = 1 => delta = (2^64-1) - ((2^64-2) - 1) + 1 = 3 NOTICE: why "+1" ? because UINT64MAX = 2^64 - 1, instead of 2^64 2.4 inpHID = 5, nodeHID = 1 => delta = (2^64-1) - (5 - 1) + 1 = 2^64 - 4 = 18446744073709551612
func GetStaticFileName ¶
GetStaticFileName is a tool function if path == "static\v1\api-v1-test\1.js", return 1.js; if path == "static\v1\api-v1-test", return ""
func LoggerGenerator ¶
LoggerGenerator is a tool function to generate *log.Entry
func ReadConfig ¶
ReadConfig is a tool func to read config file
func StaticSuffixDetermine ¶
StaticSuffixDetermine is a determiner
func StripURLPathPrefix ¶
StripURLPathPrefix is a tool function path: r.URL.Path (e.g. /api/v1/food/1.js, /api/v3/test/favicon.ico) prefix: service.proxy[i].src this function return result and ok(true) when working well while returning result("") and ok(false) when failing
Types ¶
type LoggerConfig ¶
type LoggerConfig struct { LogPath string LogFileName string LogSuffix string LogFormatter log.Formatter LogOutput io.Writer LogLevel log.Level }
LoggerConfig is a struct to contain logrus's config
type Loggerable ¶
type Loggerable interface { // Default logger should be log.NewEntry(log.New()), namely, // Logger{ Out: os.Stderr, Formatter: new(logrus.TextFormatter), Hooks: make(logrus.LevelHooks), Level: logrus.DebugLevel } // SetLogger will custom logger SetLogger(cfg *LoggerConfig) (err error) }
Loggerable is an interface balabala
type MarshalUnmarshaler ¶
type MarshalUnmarshaler interface { Marshaler Unmarshaler }
MarshalUnmarshaler is balabala
type Unmarshaler ¶
Unmarshaler is an interface
func (v interface{}) Unmarshal(res gjson.Result) turn gjson.Result => v(interface{})