Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Connection ¶
func (Connection) Release ¶
func (rc Connection) Release()
Release closes the connection and notifies the pool about the need to create a new connection. Call this method when you no longer need the connection, this is very important to keep the pool!
type ConnectionsPool ¶
type ConnectionsPool struct {
// contains filtered or unexported fields
}
func NewConnectionsPool ¶
func NewConnectionsPool( ctx context.Context, remoteAddr string, size uint, opts ...ConnectionsPoolOption, ) (ConnectionsPool, func())
NewConnectionsPool creates a new pool of connections to the remote server. The pool will create connections in the background and will keep the total number of connections equal to the size parameter. The pool will create new connections when the connection will be released using the Connection.Release method.
To close the pool and release all connections, call the returned cleanup function (it will close all connections, stop all goroutines and empty the pool of connections).
func (ConnectionsPool) Get ¶
func (cp ConnectionsPool) Get(optionalCtx ...context.Context) (Connection, bool)
Get returns an active connection from the pool. If the pool is empty, the method will block until a new connection is established and added to the pool, or the context is canceled.
Use the 2nd return value to check if the connection was successfully received.
type ConnectionsPoolOption ¶
type ConnectionsPoolOption func(*ConnectionsPool)
ConnectionsPoolOption allows you to configure the ConnectionsPool during creation.
func WithConnectionsPoolDialer ¶
func WithConnectionsPoolDialer(dialer func(context.Context, string, string) (net.Conn, error)) ConnectionsPoolOption
WithConnectionsPoolDialer sets the dialer for the ConnectionsPool. By default, the pool uses the net.Dialer.DialContext method. Useful for testing purposes.
func WithConnectionsPoolErrorsHandler ¶
func WithConnectionsPoolErrorsHandler(fn func(error)) ConnectionsPoolOption
WithConnectionsPoolErrorsHandler sets the error handler for the ConnectionsPool.
type Ngrok ¶
type Ngrok struct {
// contains filtered or unexported fields
}
func NewNgrok ¶
func NewNgrok(authToken string, opts ...NgrokOption) *Ngrok
NewNgrok creates a new Ngrok instance with the given auth token and options.
type NgrokOption ¶
type NgrokOption func(*Ngrok)
NgrokOption is a functional option for the Ngrok instance.
func WithNgrokLogger ¶
func WithNgrokLogger(log *zap.Logger) NgrokOption
WithNgrokLogger sets the logger for the Ngrok instance.