Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // DefaultClientTimeToLive is set to 1 hour. If no dial attempt succeeds, or // no messages are attempted to be sent, within one hour, then the // connection is killed and all pending messages will be lost. DefaultClientTimeToLive = time.Hour // DefaultClientMaxCapacity is set to 4096. DefaultClientMaxCapacity = 4096 )
var ( DefaultServerTimeout = 10 * time.Second DefaultServerTimeToLive = 24 * time.Hour DefaultServerMaxConns = 256 DefaultServerHost = "0.0.0.0" DefaultServerPort = uint16(18514) DefaultRateLimit = rate.Limit(1.0) DefaultRateLimitBurst = DefaultServerMaxConns )
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClient ¶
func NewClient(opts ClientOptions, handshaker handshake.Handshaker, listener wire.Listener) *Client
func (*Client) Close ¶ added in v0.4.0
Close all connections being maintained by the Client to this address. Other connections will be kept alive.
func (*Client) CloseAll ¶ added in v0.4.0
func (client *Client) CloseAll()
CloseAll connections being maintained by the Client.
func (*Client) Options ¶ added in v0.4.0
func (client *Client) Options() ClientOptions
Options returns the Options used to configure the Client. Changing the Options returned by the method will have no affect on the behaviour of the Client.
type ClientOptions ¶
type ClientOptions struct { // Logger for all information/debugging/error output. Logger logrus.FieldLogger // TimeToLive for connections. Connections with no non-malicious activity // after the TimeToLive duration will be killed. Setting the TimeToLive, and // carefully choosing which addresses to send messages to, is the primary // mechanism for ensuring that the Client does not consume too many // resources on maintaining connections (there is no explicit maximum number // of connections). This is also the amount of time that we will wait while // attempting to dial connections. TimeToLive time.Duration // MaxCapacity of messages that can be bufferred while waiting to write // messages to a channel. MaxCapacity int }
ClientOptions are used to parameterize the behaviour of the Client.
func DefaultClientOptions ¶ added in v0.4.0
func DefaultClientOptions() ClientOptions
DefaultClientOptions return the default ClientOptions.
func (ClientOptions) WithLogger ¶ added in v0.4.0
func (opts ClientOptions) WithLogger(logger logrus.FieldLogger) ClientOptions
func (ClientOptions) WithMaxCapacity ¶ added in v0.4.0
func (opts ClientOptions) WithMaxCapacity(capacity int) ClientOptions
func (ClientOptions) WithTimeToLive ¶ added in v0.4.0
func (opts ClientOptions) WithTimeToLive(ttl time.Duration) ClientOptions
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func NewServer ¶
func NewServer(opts ServerOptions, handshaker handshake.Handshaker, listener wire.Listener) *Server
func (*Server) Listen ¶
Listen for incoming connections until the context is done. The Server will accept spawn a background goroutine for every accepted connection, but will not accept more connections than its configured maximum.
func (*Server) Options ¶ added in v0.4.0
func (server *Server) Options() ServerOptions
Options returns the Options used to configure the Server. Changing the Options returned by the method will have no affect on the behaviour of the Server.
type ServerOptions ¶
type ServerOptions struct { Logger logrus.FieldLogger Timeout time.Duration TimeToLive time.Duration MaxConns int Host string Port uint16 RateLimit rate.Limit RateLimitBurst int }
func DefaultServerOptions ¶ added in v0.3.0
func DefaultServerOptions() ServerOptions
func (ServerOptions) WithHost ¶ added in v0.4.0
func (opts ServerOptions) WithHost(host string) ServerOptions
WithHost sets the host address that will be used for listening.
func (ServerOptions) WithLogger ¶ added in v0.4.0
func (opts ServerOptions) WithLogger(logger logrus.FieldLogger) ServerOptions
WithLogger sets the logger.
func (ServerOptions) WithPort ¶ added in v0.4.0
func (opts ServerOptions) WithPort(port uint16) ServerOptions
WithPort sets the port that will be used for listening.