Documentation
¶
Index ¶
- Constants
- Variables
- func EncodeAnyByteArray(s []byte) json.RawMessage
- func InetAddrString(ip uint32, port uint16) (net.IP, int)
- func InetSockAddrString(data [14]byte) (net.IP, int)
- type Action
- type AddressFamily
- type AppendFile
- type CallFromInbound
- type CallOutbound
- type ID
- func (id ID) Counter() int32
- func (id ID) Machine() []byte
- func (id ID) MarshalText() ([]byte, error)
- func (id ID) Pid() uint16
- func (id *ID) Scan(value interface{}) (err error)
- func (id ID) String() string
- func (id ID) Time() time.Time
- func (id *ID) UnmarshalText(text []byte) error
- func (id ID) Value() (driver.Value, error)
- type ReadStorage
- type ReturnInbound
- type SendUDP
- type Session
- func (si *Session) MarshalJSON() ([]byte, error)
- func (si *Session) OnSockAccept() *Session
- func (si *Session) OnSockClose(threadID uint64, socket *Socket) *Session
- func (si *Session) OnSockRecvMsg(threadID uint64, socket *Socket, unixNano uint64, data []byte, more bool) *Session
- func (si *Session) OnSockSendMsg(threadID uint64, socket *Socket, unixNano uint64, data []byte, more bool)
- func (si *Session) Release()
- func (si *Session) Reset(nextSessionID string)
- func (si *Session) Shutdown(status string) *Session
- type SockCreateBy
- type SockType
- type Socket
- type Thread
Constants ¶
const ( // Unix AF_UNIX Unix AddressFamily = 1 // Inet AF_INET Inet AddressFamily = 2 // Inet6 AF_INET6 Inet6 AddressFamily = 10 // Netlink AF_NETLINK Netlink AddressFamily = 16 // SockStream SOCK_STREAM SockStream SockType = 1 // SockDgram SOCK_DGRAM SockDgram SockType = 2 )
Variables ¶
var ErrInvalidID = errors.New("xid: invalid ID")
ErrInvalidID is returned when trying to unmarshal an invalid ID
Functions ¶
func EncodeAnyByteArray ¶
func EncodeAnyByteArray(s []byte) json.RawMessage
EncodeAnyByteArray 特殊字符转义
func InetAddrString ¶
InetAddrString converts IP address represented by uint32 to net.IP and port.
Types ¶
type Action ¶
type Action interface { IsValid() bool GetActionIndex() int GetOccurredAt() uint64 GetActionType() string }
Action defines the interface for actions performanced during the processing of a request.
type AppendFile ¶
type AppendFile struct { FileName string `json:"FileName"` Content []byte `json:"Content"` // contains filtered or unexported fields }
AppendFile represents a file append operation.
func (*AppendFile) GetActionIndex ¶
func (act *AppendFile) GetActionIndex() int
GetActionIndex returns action index.
func (*AppendFile) GetActionType ¶
func (act *AppendFile) GetActionType() string
GetActionType returns action type.
func (*AppendFile) GetOccurredAt ¶
func (act *AppendFile) GetOccurredAt() uint64
GetOccurredAt returns the time of action occurrence.
func (*AppendFile) IsValid ¶
func (af *AppendFile) IsValid() bool
IsValid returns whether this is valid action
func (*AppendFile) MarshalJSON ¶
func (af *AppendFile) MarshalJSON() ([]byte, error)
MarshalJSON json encode
type CallFromInbound ¶
type CallFromInbound struct { Peer net.TCPAddr `json:"Peer"` //UnixAddr net.UnixAddr `json:"UnixAddr"` Request []byte `json:"Request"` // contains filtered or unexported fields }
CallFromInbound represents a request of inbound.
func (*CallFromInbound) GetActionIndex ¶
func (act *CallFromInbound) GetActionIndex() int
GetActionIndex returns action index.
func (*CallFromInbound) GetActionType ¶
func (act *CallFromInbound) GetActionType() string
GetActionType returns action type.
func (*CallFromInbound) GetOccurredAt ¶
func (act *CallFromInbound) GetOccurredAt() uint64
GetOccurredAt returns the time of action occurrence.
func (*CallFromInbound) IsValid ¶
func (in *CallFromInbound) IsValid() bool
IsValid returns whether this is valid action
func (*CallFromInbound) MarshalJSON ¶
func (in *CallFromInbound) MarshalJSON() ([]byte, error)
MarshalJSON json encode
type CallOutbound ¶
type CallOutbound struct { Peer net.TCPAddr `json:"Peer"` //UnixAddr net.UnixAddr `json:"UnixAddr"` Request []byte `json:"Request"` Response []byte `json:"Response"` ResponseTime uint64 `json:"ResponseTime"` CSpanID []byte `json:"CSpanId"` Local string `json:"-"` Done bool `json:"-"` // contains filtered or unexported fields }
CallOutbound represents a rpc call of outbound.
func (*CallOutbound) GetActionIndex ¶
func (act *CallOutbound) GetActionIndex() int
GetActionIndex returns action index.
func (*CallOutbound) GetActionType ¶
func (act *CallOutbound) GetActionType() string
GetActionType returns action type.
func (*CallOutbound) GetOccurredAt ¶
func (act *CallOutbound) GetOccurredAt() uint64
GetOccurredAt returns the time of action occurrence.
func (*CallOutbound) IsValid ¶
func (out *CallOutbound) IsValid() bool
IsValid returns whether this is valid action
func (*CallOutbound) MarshalJSON ¶
func (out *CallOutbound) MarshalJSON() ([]byte, error)
MarshalJSON json encode
type ID ¶
type ID [rawLen]byte
ID represents a unique request id
func FromString ¶
FromString reads an ID from its string representation
func (ID) Counter ¶
Counter returns the incrementing value part of the id. It's a runtime error to call this method with an invalid id.
func (ID) Machine ¶
Machine returns the 3-byte machine id part of the id. It's a runtime error to call this method with an invalid id.
func (ID) MarshalText ¶
MarshalText implements encoding/text TextMarshaler interface
func (ID) Pid ¶
Pid returns the process id part of the id. It's a runtime error to call this method with an invalid id.
func (ID) String ¶
String returns a base32 hex lowercased with no padding representation of the id (char set is 0-9, a-v).
func (ID) Time ¶
Time returns the timestamp part of the id. It's a runtime error to call this method with an invalid id.
func (*ID) UnmarshalText ¶
UnmarshalText implements encoding/text TextUnmarshaler interface
type ReadStorage ¶
type ReadStorage struct { Content []byte `json:"Content"` // contains filtered or unexported fields }
ReadStorage read storage
func (*ReadStorage) GetActionIndex ¶
func (act *ReadStorage) GetActionIndex() int
GetActionIndex returns action index.
func (*ReadStorage) GetActionType ¶
func (act *ReadStorage) GetActionType() string
GetActionType returns action type.
func (*ReadStorage) GetOccurredAt ¶
func (act *ReadStorage) GetOccurredAt() uint64
GetOccurredAt returns the time of action occurrence.
func (*ReadStorage) IsValid ¶
func (rs *ReadStorage) IsValid() bool
IsValid returns whether this is valid action
func (*ReadStorage) MarshalJSON ¶
func (rs *ReadStorage) MarshalJSON() ([]byte, error)
MarshalJSON json encode
type ReturnInbound ¶
type ReturnInbound struct { Response []byte `json:"Response"` // contains filtered or unexported fields }
ReturnInbound represents a response of inbound.
func (*ReturnInbound) GetActionIndex ¶
func (act *ReturnInbound) GetActionIndex() int
GetActionIndex returns action index.
func (*ReturnInbound) GetActionType ¶
func (act *ReturnInbound) GetActionType() string
GetActionType returns action type.
func (*ReturnInbound) GetOccurredAt ¶
func (act *ReturnInbound) GetOccurredAt() uint64
GetOccurredAt returns the time of action occurrence.
func (*ReturnInbound) IsValid ¶
func (in *ReturnInbound) IsValid() bool
IsValid returns whether this is valid action
func (*ReturnInbound) MarshalJSON ¶
func (in *ReturnInbound) MarshalJSON() ([]byte, error)
MarshalJSON json encode
type SendUDP ¶
type SendUDP struct { Peer net.UDPAddr `json:"Peer"` Content []byte `json:"Content"` // contains filtered or unexported fields }
SendUDP represents a udp send operation.
func (*SendUDP) GetActionIndex ¶
func (act *SendUDP) GetActionIndex() int
GetActionIndex returns action index.
func (*SendUDP) GetActionType ¶
func (act *SendUDP) GetActionType() string
GetActionType returns action type.
func (*SendUDP) GetOccurredAt ¶
func (act *SendUDP) GetOccurredAt() uint64
GetOccurredAt returns the time of action occurrence.
func (*SendUDP) MarshalJSON ¶
MarshalJSON json encode
type Session ¶
type Session struct { ServiceName string `json:"ServiceName"` Cluster string `json:"Cluster"` Context string `json:"Context"` ThreadID uint64 `json:"ThreadId"` SessionID string `json:"SessionId"` SpanID string `json:"SpanId"` NextSessionID string `json:"NextSessionId"` InboundRequest *CallFromInbound `json:"CallFromInbound"` InboundResponse *ReturnInbound `json:"ReturnInbound"` Actions []Action `json:"Actions"` Status string `json:"Status"` Timestamp uint64 `json:"timestamp"` LastAccess time.Time `json:"-"` DataLost int `json:"-"` UDPLost int `json:"-"` MaxActions int `json:"-"` // contains filtered or unexported fields }
Session contains all actions performanced during the processing of a request, including request, response and all rpc calls.
func NewSession ¶
NewSession new session
func (*Session) MarshalJSON ¶
MarshalJSON json encode
func (*Session) OnSockAccept ¶
OnSockAccept is the callback for socket accept event.
func (*Session) OnSockClose ¶
OnSockClose is the callback for socket close event.
func (*Session) OnSockRecvMsg ¶
func (si *Session) OnSockRecvMsg(threadID uint64, socket *Socket, unixNano uint64, data []byte, more bool) *Session
OnSockRecvMsg is the callback for socket recv event.
func (*Session) OnSockSendMsg ¶
func (si *Session) OnSockSendMsg(threadID uint64, socket *Socket, unixNano uint64, data []byte, more bool)
OnSockSendMsg is the callback for socket send event.
func (*Session) Release ¶
func (si *Session) Release()
Release frees the session and makes buffers reusable.