model

package
v0.0.0-...-ed86471 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 29, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
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

View Source
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

func InetAddrString(ip uint32, port uint16) (net.IP, int)

InetAddrString converts IP address represented by uint32 to net.IP and port.

func InetSockAddrString

func InetSockAddrString(data [14]byte) (net.IP, int)

InetSockAddrString parses IP address and port from sockaddr.sa_data.

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 AddressFamily

type AddressFamily uint16

AddressFamily address family

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

func FromString(id string) (ID, error)

FromString reads an ID from its string representation

func (ID) Counter

func (id ID) Counter() int32

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

func (id ID) Machine() []byte

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

func (id ID) MarshalText() ([]byte, error)

MarshalText implements encoding/text TextMarshaler interface

func (ID) Pid

func (id ID) Pid() uint16

Pid returns the process id part of the id. It's a runtime error to call this method with an invalid id.

func (*ID) Scan

func (id *ID) Scan(value interface{}) (err error)

Scan implements the sql.Scanner interface.

func (ID) String

func (id ID) String() string

String returns a base32 hex lowercased with no padding representation of the id (char set is 0-9, a-v).

func (ID) Time

func (id ID) Time() time.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

func (id *ID) UnmarshalText(text []byte) error

UnmarshalText implements encoding/text TextUnmarshaler interface

func (ID) Value

func (id ID) Value() (driver.Value, error)

Value implements the driver.Valuer 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) IsValid

func (su *SendUDP) IsValid() bool

IsValid returns whether this is valid action

func (*SendUDP) MarshalJSON

func (su *SendUDP) MarshalJSON() ([]byte, error)

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

func NewSession(service, cluster, ctx string, threadID uint64, maxActions int) *Session

NewSession new session

func (*Session) MarshalJSON

func (si *Session) MarshalJSON() ([]byte, error)

MarshalJSON json encode

func (*Session) OnSockAccept

func (si *Session) OnSockAccept() *Session

OnSockAccept is the callback for socket accept event.

func (*Session) OnSockClose

func (si *Session) OnSockClose(threadID uint64, socket *Socket) *Session

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.

func (*Session) Reset

func (si *Session) Reset(nextSessionID string)

Reset resets the session for reuse.

func (*Session) Shutdown

func (si *Session) Shutdown(status string) *Session

Shutdown finishes the session and returns a clone session.

type SockCreateBy

type SockCreateBy uint8
const (
	Unknown SockCreateBy = iota
	Accept
	Connect
)

type SockType

type SockType uint16

SockType socket type

type Socket

type Socket struct {
	ID         uint64
	CreateBy   SockCreateBy
	Reset      bool
	Family     AddressFamily
	Type       SockType
	LocalAddr  string
	PeerAddr   string
	PeerIPAddr net.IP
	PeerPort   int
	SendOffset uint32
	RecvOffset uint32
	LastAccess time.Time
	TraceID    string
}

Socket saves socket info

type Thread

type Thread struct {
	ID         uint64
	ParentID   uint64
	LastAccess time.Time
}

Thread saves thread info

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL