Documentation ¶
Overview ¶
Package fasthttputil provides utility functions for fasthttp.
Index ¶
- Variables
- type InmemoryListener
- func (ln *InmemoryListener) Accept() (net.Conn, error)
- func (ln *InmemoryListener) Addr() net.Addr
- func (ln *InmemoryListener) Close() error
- func (ln *InmemoryListener) Dial() (net.Conn, error)
- func (ln *InmemoryListener) DialWithLocalAddr(local net.Addr) (net.Conn, error)
- func (ln *InmemoryListener) SetLocalAddr(localAddr net.Addr)
- type PipeConns
Constants ¶
This section is empty.
Variables ¶
var ErrInmemoryListenerClosed = errors.New("InmemoryListener is already closed: use of closed network connection")
ErrInmemoryListenerClosed indicates that the InmemoryListener is already closed.
var (
// ErrTimeout is returned from Read() or Write() on timeout.
ErrTimeout = &timeoutError{}
)
Functions ¶
This section is empty.
Types ¶
type InmemoryListener ¶
type InmemoryListener struct {
// contains filtered or unexported fields
}
InmemoryListener provides in-memory dialer<->net.Listener implementation.
It may be used either for fast in-process client<->server communications without network stack overhead or for client<->server tests.
func NewInmemoryListener ¶
func NewInmemoryListener() *InmemoryListener
NewInmemoryListener returns new in-memory dialer<->net.Listener.
func (*InmemoryListener) Accept ¶
func (ln *InmemoryListener) Accept() (net.Conn, error)
Accept implements net.Listener's Accept.
It is safe calling Accept from concurrently running goroutines.
Accept returns new connection per each Dial call.
func (*InmemoryListener) Addr ¶
func (ln *InmemoryListener) Addr() net.Addr
Addr implements net.Listener's Addr.
func (*InmemoryListener) Close ¶
func (ln *InmemoryListener) Close() error
Close implements net.Listener's Close.
func (*InmemoryListener) Dial ¶
func (ln *InmemoryListener) Dial() (net.Conn, error)
Dial creates new client<->server connection. Just like a real Dial it only returns once the server has accepted the connection.
It is safe calling Dial from concurrently running goroutines.
func (*InmemoryListener) DialWithLocalAddr ¶
DialWithLocalAddr creates new client<->server connection. Just like a real Dial it only returns once the server has accepted the connection. The local address of the client connection can be set with local.
It is safe calling Dial from concurrently running goroutines.
func (*InmemoryListener) SetLocalAddr ¶
func (ln *InmemoryListener) SetLocalAddr(localAddr net.Addr)
SetLocalAddr sets the (simulated) local address for the listener.
type PipeConns ¶
type PipeConns struct {
// contains filtered or unexported fields
}
PipeConns provides bi-directional connection pipe, which use in-process memory as a transport.
PipeConns must be created by calling NewPipeConns.
PipeConns has the following additional features comparing to connections returned from net.Pipe():
- It is faster.
- It buffers Write calls, so there is no need to have concurrent goroutine calling Read in order to unblock each Write call.
- It supports read and write deadlines.
PipeConns is NOT safe for concurrent use by multiple goroutines!
func NewPipeConns ¶
func NewPipeConns() *PipeConns
NewPipeConns returns new bi-directional connection pipe.
PipeConns is NOT safe for concurrent use by multiple goroutines!
func (*PipeConns) Conn1 ¶
Conn1 returns the first end of bi-directional pipe.
Data written to Conn1 may be read from Conn2. Data written to Conn2 may be read from Conn1.
func (*PipeConns) Conn2 ¶
Conn2 returns the second end of bi-directional pipe.
Data written to Conn2 may be read from Conn1. Data written to Conn1 may be read from Conn2.
func (*PipeConns) SetAddresses ¶
SetAddresses sets the local and remote addresses for the connection.