Documentation ¶
Overview ¶
Package tlv provides 'Type-Length-Value' building blocks for fastrpc.
See https://en.wikipedia.org/wiki/Type-length-value for details.
Index ¶
- func ReleaseRequest(req *Request)
- func ReleaseResponse(resp *Response)
- type Request
- func (req *Request) Append(p []byte)
- func (req *Request) Name() []byte
- func (req *Request) ReadRequest(br *bufio.Reader) error
- func (req *Request) Reset()
- func (req *Request) SetName(name string)
- func (req *Request) SetNameBytes(name []byte)
- func (req *Request) SwapValue(value []byte) []byte
- func (req *Request) Value() []byte
- func (req *Request) Write(p []byte) (int, error)
- func (req *Request) WriteRequest(bw *bufio.Writer) error
- type RequestCtx
- func (ctx *RequestCtx) ConcurrencyLimitError(concurrency int)
- func (ctx *RequestCtx) Conn() net.Conn
- func (ctx *RequestCtx) Init(conn net.Conn, logger fasthttp.Logger)
- func (ctx *RequestCtx) LocalAddr() net.Addr
- func (ctx *RequestCtx) Logger() fasthttp.Logger
- func (ctx *RequestCtx) ReadRequest(br *bufio.Reader) error
- func (ctx *RequestCtx) RemoteAddr() net.Addr
- func (ctx *RequestCtx) RemoteIP() net.IP
- func (ctx *RequestCtx) Write(p []byte) (int, error)
- func (ctx *RequestCtx) WriteResponse(bw *bufio.Writer) error
- type Response
- func (resp *Response) Append(p []byte)
- func (resp *Response) ReadResponse(br *bufio.Reader) error
- func (resp *Response) Reset()
- func (resp *Response) SwapValue(value []byte) []byte
- func (resp *Response) Value() []byte
- func (resp *Response) Write(p []byte) (int, error)
- func (resp *Response) WriteResponse(bw *bufio.Writer) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 (*Request) Name ¶
Name returns request name.
The returned value is valid until the next Request method call or until ReleaseRequest is called.
func (*Request) ReadRequest ¶
ReadRequest reads the request from br.
func (*Request) SetNameBytes ¶
SetNameBytes set request name.
func (*Request) SwapValue ¶
SwapValue swaps the given value with the request's value.
It is forbidden accessing the swapped value after the call.
func (*Request) Value ¶
Value returns request value.
The returned value is valid until the next Request method call. or until ReleaseRequest is called.
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 (*Response) ReadResponse ¶
ReadResponse reads the response from br.
It implements fastrpc.ReadResponse.
func (*Response) SwapValue ¶
SwapValue swaps the given value with the response's value.
It is forbidden accessing the swapped value after the call.
func (*Response) Value ¶
Value returns response value.
The returned value is valid until the next Response method call. or until ReleaseResponse is called.