proto

package
v0.0.0-...-1e30a20 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Args

type Args struct {
	Method     string              `json:"method,omitempty"` // http method
	URL        string              `json:"url,omitempty"`
	Headers    map[string][]string `json:"headers,omitempty"`
	Client     string              `json:"client,omitempty"`
	WSID       string              `json:"ws_id,omitempty"`
	Msg        string              `json:"msg,omitempty"`
	StatusCode int64               `json:"status_code,omitempty"`
	Exception  string              `json:"exception,omitempty"`
	Body       []byte              `json:"body,omitempty"`
}

func MakeHTTPErrprRespArgs

func MakeHTTPErrprRespArgs(statusCode int) *Args

func MakeHTTPReqArgs

func MakeHTTPReqArgs(ctx context.Context, r *http.Request) (*Args, error)

func MakeHTTPRespArgs

func MakeHTTPRespArgs(ctx context.Context, r *http.Response) (*Args, error)

func (*Args) String

func (args *Args) String() string

func (*Args) UrlTransform

func (args *Args) UrlTransform() (string, error)

urlTransform replaces original url to bridging-base-url.

func (*Args) WsUrlTransform

func (args *Args) WsUrlTransform() (*url.URL, error)

wsUrlTransform is the sibling function to urlTransform for websocket destination.

type Packet

type Packet struct {
	CorrID string       `json:"corr_id"`
	Method PacketMethod `json:"method"`
	Args   *Args        `json:"args"`
}

func Deserialize

func Deserialize(ctx context.Context, data []byte) (*Packet, error)

func (*Packet) Serialize

func (p *Packet) Serialize(ctx context.Context, compressor *gzip.Writer) ([]byte, error)

Serialize converts the packet into byte array by json marshalling, and gzipped if compressor is not nil. caller can reuse the same compressor to reduce cpu usage.

func (*Packet) SerializeJSON

func (p *Packet) SerializeJSON(ctx context.Context) ([]byte, error)

func (*Packet) String

func (p *Packet) String() string

type PacketMethod

type PacketMethod string
const (
	OPEN_WEBSOCKET_RESULT  PacketMethod = "open_websocket_result"
	OPEN_WEBSOCKET         PacketMethod = "open_websocket"
	CLOSE_WEBSOCKET_RESULT PacketMethod = "close_websocket_result"
	CLOSE_WEBSOCKET        PacketMethod = "close_websocket"
	WEBSOCKET_MSG          PacketMethod = "websocket_msg"
	HTTP_RESULT            PacketMethod = "http_result"
	HTTP                   PacketMethod = "http"
)

Jump to

Keyboard shortcuts

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