Documentation ¶
Overview ¶
Package protocol implements the VelocyStream protocol (it is not intended to be used directly).
Index ¶
Constants ¶
const ( DefaultIdleConnTimeout = time.Minute DefaultConnLimit = 3 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
Connection is a single socket connection to a server.
func (*Connection) IsClosed ¶
func (c *Connection) IsClosed() bool
IsClosed returns true when the connection is closed, false otherwise.
func (*Connection) IsConfigured ¶
func (c *Connection) IsConfigured() bool
IsConfigured returns true when the configuration callback has finished on this connection, without errors.
func (*Connection) IsIdle ¶
func (c *Connection) IsIdle(idleTimeout time.Duration) bool
IsIdle returns true when the last activity was more than the given timeout ago.
type Transport ¶
type Transport struct { TransportConfig // contains filtered or unexported fields }
Transport manages client-server connections using the VST protocol to a specific host.
func NewTransport ¶
func NewTransport(hostAddr string, tlsConfig *tls.Config, config TransportConfig) *Transport
NewTransport creates a new Transport for given address & tls settings.
func (*Transport) CloseAllConnections ¶
func (c *Transport) CloseAllConnections()
CloseAllConnections closes all connections.
func (*Transport) CloseIdleConnections ¶
CloseIdleConnections closes all connections which are closed or have been idle for more than the configured idle timeout.
func (*Transport) Send ¶
Send sends a message (consisting of given parts) to the server and returns a channel on which the response will be delivered. When the connection is closed before a response was received, the returned channel will be closed.
func (*Transport) SetOnConnectionCreated ¶
func (c *Transport) SetOnConnectionCreated(handler func(context.Context, *Connection) error)
SetOnConnectionCreated stores a callback function that is called every time a new connection has been created.
type TransportConfig ¶
type TransportConfig struct { // IdleConnTimeout is the maximum amount of time an idle // (keep-alive) connection will remain idle before closing // itself. // Zero means no limit. IdleConnTimeout time.Duration // ConnLimit is the upper limit to the number of connections to a single server. // Due to the nature of the VST protocol, this value does not have to be high. // The default is 3 (DefaultConnLimit). ConnLimit int // Version specifies the version of the Velocystream protocol Version Version }
TransportConfig contains configuration options for Transport.