Documentation
¶
Index ¶
Constants ¶
const ( Accept EventType = iota + 1 Connect Receive Send Shutdown // extra flags associated with the Shut event type ShutRD = 1 << 6 ShutWR = 1 << 7 // mask to extract the even type or flags independently EventTypeMask = 0b00111111 EventFlagMask = 0b11000000 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Conn ¶
type Conn interface {
// Returns the protocol that this Conn value was constructed from.
Protocol() ConnProtocol
// Observe is called when a network event is received for this connection.
//
// The receiver is expected to update its state by capturing the data
// fragments carried in the event.
Observe(*Event)
// After calls to Observe, the connection may receive a call to Next in
// order to consume the next message that was formed by the accumulation of
// data fragements from network events.
//
// The method writes to the Message value passed as argument, returning true
// if a message could be formed, and false otherwise.
Next(*Message) bool
// Indicates whether the connection has reached EOF, and has no more
// messages to read.
Done() bool
}
Conn values represent client and server connections.
The instances are intended to reconstruct the state of a connection from observing a sequence of network events which contain data fragments seen by the connection.
type ConnMessage ¶
type ConnMessage interface {
// Returns the connection that the message was originally decoded from.
Conn() Conn
// Marshals the message into a representation intended to be marshaled to
// structured formats like JSON or YAML.
Marshal() any
// Formats the message to a human readable format.
fmt.Formatter
}
ConnMessage represents a message read from a client or server connection.
type ConnProtocol ¶
type ConnProtocol interface {
// Returns the name of the protocol.
//
// This value is used when printing protocol messages in a human readable
// format.
Name() string
// Given a data segment found at the beginning of a network connection,
// determine whether the protocol is able to decode it.
//
// This method is used to do automatic detection of the protocol being used
// when inspecting network events.
CanHandle(data []byte) bool
// Constructs a Conn instance intended to decode protocol messages exchanged
// over a client connection.
NewClient(fd wasi.FD, addr, peer net.Addr) Conn
// Constructs a Conn instance intended to decode protocol messages exchanged
// over a server connection.
NewServer(fd wasi.FD, addr, peer net.Addr) Conn
}
ConnProtocol is an interface implemented by types which represent high level connection-oriented protocols such as HTTP.
type Event ¶
type Event struct {
Record int64 `json:"record" yaml:"record"`
Time time.Time `json:"time" yaml:"time"`
Type EventType `json:"type" yaml:"type"`
Proto Protocol `json:"proto" yaml:"proto"`
Error wasi.Errno `json:"error,omitempty" yaml:"error,omitempty"`
FD wasi.FD `json:"fd" yaml:"fd"`
Addr net.Addr `json:"addr,omitempty" yaml:"addr,omitempty"`
Peer net.Addr `json:"peer,omitempty" yaml:"peer,omitempty"`
Data []Bytes `json:"data,omitempty" yaml:"data,omitempty"`
}
type EventReader ¶
type EventReader struct {
Records stream.Reader[timemachine.Record]
// contains filtered or unexported fields
}
type EventType ¶
type EventType uint8
func (EventType) MarshalText ¶
func (*EventType) UnmarshalText ¶
type Exchange ¶
Exchange values represent the exchange of a request and response between network peers.
func (Exchange) MarshalJSON ¶
func (Exchange) MarshalYAML ¶
type ExchangeReader ¶
type ExchangeReader struct {
Messages stream.Reader[Message]
// contains filtered or unexported fields
}
ExchangeReader is a reader of Exchange values. Instances of ExchangeReader consume network messages from a reader of Message values and reconstruct the relationship between requests and responses.
type Link ¶
Link represents a network connection initiated from a source address to a local or remote destination.
type Message ¶
type Message struct {
Link Link
Time time.Time
Span time.Duration
Err error
// contains filtered or unexported fields
}
Message is a representation of a message exchanged between two network peers.
func (Message) MarshalJSON ¶
func (Message) MarshalYAML ¶
type MessageReader ¶
type MessageReader struct {
Events stream.Reader[Event]
Protos []ConnProtocol
// contains filtered or unexported fields
}
MessageReader is a reader of Message values. Instances of MessageReader consume network events from a reader of Event values and reconstruct network messages exchanged over network connections.