decode

package
v0.165.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package decode turns "msg" events of a wire trace into logical messages: containers are split, wrappers (invokeWithLayer, initConnection, invokeAfterMsg, ...) are unwrapped, rpc_result is joined with its request (method, latency, request id and caller).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Caller

type Caller struct {
	File      string `json:"file,omitempty"`
	Line      int64  `json:"line,omitempty"`
	Function  string `json:"function,omitempty"`
	Subsystem string `json:"subsystem,omitempty"`
}

Caller is the call site of a request (req.caller).

type Decoder

type Decoder struct {
	// contains filtered or unexported fields
}

Decoder decodes "msg" events into logical messages.

Feed every event to Index first (pass 1), then call Messages for "msg" events (pass 2). Index collects facts that may be written after the message they describe (req.caller is emitted from another thread).

func New

func New(schema *tljson.Schema, opt Options) *Decoder

New creates a Decoder.

func (*Decoder) Index

func (d *Decoder) Index(ev *wiretrace.Event)

Index records request and message facts from an event (pass 1).

func (*Decoder) Messages

func (d *Decoder) Messages(ev *wiretrace.Event, body []byte) ([]Message, error)

Messages decodes a "msg" event with its body into logical messages.

func (*Decoder) Schema

func (d *Decoder) Schema() *tljson.Schema

Schema returns the schema of the decoder.

type Message

type Message struct {
	Seq       uint64   `json:"seq"`
	T         float64  `json:"t"`
	Dir       string   `json:"dir"`
	SDC       int      `json:"sdc"`
	Session   string   `json:"session"`
	MsgID     string   `json:"msg_id"`
	SeqNo     int64    `json:"seqno"`
	Container string   `json:"container,omitempty"`
	Gzip      bool     `json:"gzip,omitempty"`
	Wrap      []string `json:"wrap,omitempty"`
	// After is the target msg_id of invokeAfterMsg(s) (the last one).
	After       string `json:"after,omitempty"`
	AfterMethod string `json:"after_method,omitempty"`
	// Type is the constructor (or function) of the message body.
	Type string `json:"type"`
	// Method is the innermost method of an outgoing query, or the method of
	// the request an rpc_result answers.
	Method string  `json:"method,omitempty"`
	Req    int64   `json:"req,omitempty"`
	Caller *Caller `json:"caller,omitempty"`
	// ReqMsgID, Result, LatencyMS and Error are set for rpc_result.
	ReqMsgID  string    `json:"req_msg_id,omitempty"`
	Result    string    `json:"result,omitempty"`
	LatencyMS *float64  `json:"latency_ms,omitempty"`
	Error     *RPCError `json:"error,omitempty"`

	Redacted    []string `json:"redacted,omitempty"`
	Partial     bool     `json:"partial,omitempty"`
	DecodeError string   `json:"decode_error,omitempty"`
	Body        any      `json:"body"`

	// MsgIDValue is the numeric MsgID.
	MsgIDValue uint64 `json:"-"`
	// TypeID is the constructor id of the body (after gzip).
	TypeID uint32 `json:"-"`
	// MethodID is the id of Method, if known.
	MethodID uint32 `json:"-"`
}

Message is one logical MTProto message.

type Options

type Options struct {
	// MaxBytes is passed to tljson.Decoder.
	MaxBytes int
}

Options configures Decoder.

type RPCError

type RPCError struct {
	Code    int32  `json:"code"`
	Message string `json:"message"`
}

RPCError is a decoded rpc_error.

Jump to

Keyboard shortcuts

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