tlv

package
v0.0.0-...-0b1a558 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2017 License: MIT Imports: 6 Imported by: 2

Documentation

Overview

Package tlv provides 'Type-Length-Value' building blocks for fastrpc.

See https://en.wikipedia.org/wiki/Type-length-value for details.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReleaseRequest

func ReleaseRequest(req *Request)

ReleaseRequest releases the given request.

func ReleaseResponse

func ReleaseResponse(resp *Response)

ReleaseResponse releases the given response.

Types

type Request

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

Request is a TLV request.

func AcquireRequest

func AcquireRequest() *Request

AcquireRequest acquires new request.

func (*Request) Append

func (req *Request) Append(p []byte)

Append appends p to the request value.

func (*Request) Name

func (req *Request) Name() []byte

Name returns request name.

The returned value is valid until the next Request method call or until ReleaseRequest is called.

func (*Request) ReadRequest

func (req *Request) ReadRequest(br *bufio.Reader) error

ReadRequest reads the request from br.

func (*Request) Reset

func (req *Request) Reset()

Reset resets the given request.

func (*Request) SetName

func (req *Request) SetName(name string)

SetName sets request name.

func (*Request) SetNameBytes

func (req *Request) SetNameBytes(name []byte)

SetNameBytes set request name.

func (*Request) SwapValue

func (req *Request) SwapValue(value []byte) []byte

SwapValue swaps the given value with the request's value.

It is forbidden accessing the swapped value after the call.

func (*Request) Value

func (req *Request) Value() []byte

Value returns request value.

The returned value is valid until the next Request method call. or until ReleaseRequest is called.

func (*Request) Write

func (req *Request) Write(p []byte) (int, error)

Write appends p to the request value.

It implements io.Writer.

func (*Request) WriteRequest

func (req *Request) WriteRequest(bw *bufio.Writer) error

WriteRequest writes the request to bw.

It implements fastrpc.RequestWriter

type RequestCtx

type RequestCtx struct {
	// ConcurrencyLimitErrorHandler is called each time concurrency limit
	// is reached on the fastrpc.Server.
	ConcurrencyLimitErrorHandler func(ctx *RequestCtx, concurrency int)

	Request  Request
	Response Response
	// contains filtered or unexported fields
}

RequestCtx implements fastrpc.HandlerCtx

func (*RequestCtx) ConcurrencyLimitError

func (ctx *RequestCtx) ConcurrencyLimitError(concurrency int)

ConcurrencyLimitError implements the corresponding method of fastrpc.HandlerCtx.

func (*RequestCtx) Conn

func (ctx *RequestCtx) Conn() net.Conn

Conn returns connection associated with the current RequestCtx.

func (*RequestCtx) Init

func (ctx *RequestCtx) Init(conn net.Conn, logger fasthttp.Logger)

Init implements the corresponding method of fastrpc.HandlerCtx.

func (*RequestCtx) LocalAddr

func (ctx *RequestCtx) LocalAddr() net.Addr

LocalAddr returns server address for the given request.

Always returns non-nil result.

func (*RequestCtx) Logger

func (ctx *RequestCtx) Logger() fasthttp.Logger

Logger returns logger associated with the current RequestCtx.

func (*RequestCtx) ReadRequest

func (ctx *RequestCtx) ReadRequest(br *bufio.Reader) error

ReadRequest implements the corresponding method of fastrpc.HandlerCtx.

func (*RequestCtx) RemoteAddr

func (ctx *RequestCtx) RemoteAddr() net.Addr

RemoteAddr returns client address for the given request.

Always returns non-nil result.

func (*RequestCtx) RemoteIP

func (ctx *RequestCtx) RemoteIP() net.IP

RemoteIP returns client ip for the given request.

Always returns non-nil result.

func (*RequestCtx) Write

func (ctx *RequestCtx) Write(p []byte) (int, error)

Write appends p to ctx.Response's value.

It implements io.Writer.

func (*RequestCtx) WriteResponse

func (ctx *RequestCtx) WriteResponse(bw *bufio.Writer) error

WriteResponse implements the corresponding method of fastrpc.HandlerCtx.

type Response

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

Response is a TLV response.

func AcquireResponse

func AcquireResponse() *Response

AcquireResponse acquires new response.

func (*Response) Append

func (resp *Response) Append(p []byte)

Append appends p to the response value.

func (*Response) ReadResponse

func (resp *Response) ReadResponse(br *bufio.Reader) error

ReadResponse reads the response from br.

It implements fastrpc.ReadResponse.

func (*Response) Reset

func (resp *Response) Reset()

Reset resets the given response.

func (*Response) SwapValue

func (resp *Response) SwapValue(value []byte) []byte

SwapValue swaps the given value with the response's value.

It is forbidden accessing the swapped value after the call.

func (*Response) Value

func (resp *Response) Value() []byte

Value returns response value.

The returned value is valid until the next Response method call. or until ReleaseResponse is called.

func (*Response) Write

func (resp *Response) Write(p []byte) (int, error)

Write appends p to the response value.

It implements io.Writer.

func (*Response) WriteResponse

func (resp *Response) WriteResponse(bw *bufio.Writer) error

WriteResponse writes the response to bw.

Jump to

Keyboard shortcuts

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