Documentation ¶
Index ¶
- Variables
- func AbnormalExit()
- func BackupFile(path string, bakPath string) error
- func CheckNilField(object interface{}, allowNoPointerField bool) error
- func CheckStaticFile(filename string, sizeLimit int64) error
- func ConfPathProc(confPath string, confRoot string) string
- func CopyFile(src, dst string) (int64, error)
- func CopyWithoutBuffer(wf bfe_http.WriteFlusher, src io.Reader) (written int64, err error)
- func DumpJson(jsonObject interface{}, filePath string, perm os.FileMode) error
- func GetConnFile(conn net.Conn) (*os.File, error)
- func GetTCPConn(conn net.Conn) (*net.TCPConn, error)
- func GetVip(conn net.Conn) net.IP
- func GetVipPort(conn net.Conn) (net.IP, int, error)
- func GetsockoptMultiByte(fd, level, opt int) ([]byte, error)
- func IsBigEndian() bool
- func LoadJsonFile(path string, jsonObject interface{}) error
- func NativeUint16(data []byte) uint16
- func ParseIpAndPort(addr string) (net.IP, int, error)
- func ParseTime(timeStr string) (time.Time, error)
- func ParseTimeOfDay(timeStr string) (time.Time, int, error)
- type AddressFetcher
- type CloseWriter
- type ConnFetcher
- type FixedPool
- type MockConn
- type MockHandler
- type MockServer
Constants ¶
This section is empty.
Variables ¶
var ( // TimeZoneMap reference: https://en.wikipedia.org/wiki/List_of_military_time_zones TimeZoneMap = map[string]int{ "Y": -12 * 3600, "X": -11 * 3600, "W": -10 * 3600, "V": -9 * 3600, "U": -8 * 3600, "T": -7 * 3600, "S": -6 * 3600, "R": -5 * 3600, "Q": -4 * 3600, "P": -3 * 3600, "O": -2 * 3600, "N": -1 * 3600, "Z": 0, "A": 1 * 3600, "B": 2 * 3600, "C": 3 * 3600, "D": 4 * 3600, "E": 5 * 3600, "F": 6 * 3600, "G": 7 * 3600, "H": 8 * 3600, "I": 9 * 3600, "K": 10 * 3600, "L": 11 * 3600, "M": 12 * 3600, } )
Functions ¶
func AbnormalExit ¶
func AbnormalExit()
func CheckNilField ¶
CheckNilField check if a struct has a nil field if allowNoPointerField is false, it also check if fields are all pointers if param object is not a struct , return nil
func CheckStaticFile ¶
CheckStaticFile check local file
func ConfPathProc ¶
ConfPathProc return path of config file
Params:
- confPath: origin path for config file
- confRoot: root path of ALL config
Returns:
the final path of config file (1) path starts with "/", it's absolute path, return path untouched (2) else, it's relative path, return path.Join(confRoot, path)
func CopyWithoutBuffer ¶
CopyWithoutBuffer mimic the behavior of io.Copy.
func GetConnFile ¶
GetConnFile get a copy of underlying os.File of tcp conn
func GetTCPConn ¶
GetTCPConn returns underlying TCPConn of given conn.
func GetVipPort ¶
GetVipPort return vip and port for given conn
func GetsockoptMultiByte ¶ added in v1.6.0
GetsockoptMultiByte returns the value of the socket option opt for the socket associated with fd at the given socket level.
func LoadJsonFile ¶
LoadJsonFile loads json content from file, unmarshal to jsonObject. check if all field is set if checkNilPointer is true check if any field is not pointer type if allowNoPointerField is false
func NativeUint16 ¶
func ParseIpAndPort ¶
ParseIpAndPort return parsed ip address
func ParseTime ¶ added in v1.2.0
ParseTime returns a time in UTC+0 time zone. Note: currently, we do not use time.LoadLocation func, because it has two issues: 1. abusing opening files: https://github.com/golang/go/issues/24844 2. the version of zone info file in all machines may differ.
Types ¶
type AddressFetcher ¶
type AddressFetcher interface { // RemoteAddr returns the remote network address. RemoteAddr() net.Addr // LocalAddr returns the local network address. LocalAddr() net.Addr // VirtualAddr returns the virtual network address. VirtualAddr() net.Addr // BalancerAddr return the balancer network address. May be nil. BalancerAddr() net.Addr }
AddressFetcher is the interface that group the address related method.
type CloseWriter ¶
type CloseWriter interface {
CloseWrite() error
}
CloseWriter is the interface that wraps the basic CloseWrite method.
type ConnFetcher ¶
ConnFetcher is the interface that wrap the GetNetConn
type FixedPool ¶
type FixedPool struct {
// contains filtered or unexported fields
}
func NewFixedPool ¶
type MockHandler ¶
A MockHandler is an handler to process established conn on server side
type MockServer ¶
type MockServer struct { Listener net.Listener // optional fields for tls server TLS *tls.Config Config *http.Server // optional fields for tcp server Handler MockHandler }
A MockServer is an tls/tcp server listening on a system-chosen port on the local loopback interface, for use in end-to-end tests.
func NewUnstartedServer ¶
func NewUnstartedServer(handler interface{}) *MockServer
NewUnstartedServer returns a new Server but doesn't start it. After changing its configuration, the caller should call StartTLS. The caller should call Close when finished, to shut it down.
func (*MockServer) Close ¶
func (s *MockServer) Close()
Close shuts down the server and blocks until all outstanding requests on this server have completed.
func (*MockServer) CloseClientConnections ¶
func (s *MockServer) CloseClientConnections()
CloseClientConnections closes any currently open HTTP connections to the test Server.
func (*MockServer) StartTCP ¶
func (s *MockServer) StartTCP()
StartTCP starts TCP on a server from NewUnstartedServer.
func (*MockServer) StartTLS ¶
func (s *MockServer) StartTLS()
StartTLS starts TLS on a server from NewUnstartedServer.