Documentation
¶
Index ¶
Constants ¶
const ( // DefaultDialConnectionTimeout is the default timeout for a dial operation. DefaultDialConnectionTimeout = 2 * time.Second // DefaultListenConnectionKeepAlive is the default keep alive checking interval for listening threads. DefaultListenConnectionKeepAlive = 20 * time.Second )
const ListenerWaitTimeout = 5 * time.Minute
ListenerWaitTimeout specifies the duration for the listener to close the connection without receiving heartbeat from router.
const MaxChannelNameLength = 256
MaxChannelNameLength limits the maxmimum length of a channel name.
Variables ¶
var DefaultRouterOption = Option{ TokenAuthority: &noPermissionCheckAuthority{}, DialConnectionTimeout: DefaultDialConnectionTimeout, ListenConnectionKeepAlive: DefaultListenConnectionKeepAlive, }
DefaultRouterOption is a set of parameters in default value.
Functions ¶
Types ¶
type Address ¶
type Address struct {
Channel string
}
Address represents an address in Router network.
type Authority ¶
type Authority interface { // Only returns a PeerInfo when the connection has the access permission. ValidatePeerInfo(*Frame, net.Conn) (*PeerInfo, error) }
Authority will be used by the router for ACL control.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client implements a Dial method to join the Router network.
func NewClientWithoutAuth ¶
NewClientWithoutAuth creates a RouterClient structure.
func (*Client) ScanChannel ¶ added in v0.0.38
func (client *Client) ScanChannel(ChannelRegexp string) (*ListenerScanResult, error)
ScanChannel returns the list of acessible channels.
type Listener ¶
type Listener struct {
// contains filtered or unexported fields
}
Listener implements a net.Listener interface on Router network.
func NewListener ¶
NewListener creates a RouterListener.
func NewListenerWithoutAuth ¶
NewListenerWithoutAuth creates a RouterListener structure and try to handshake with Router in `RouterAddress`.
func NewRouterListenerWithConn ¶
func NewRouterListenerWithConn( RouterAddress string, Channel string, RouterAddressDialer func(string) (net.Conn, error)) (*Listener, error)
NewRouterListenerWithConn creates a RouterListener structure. Conn here can be a just initialized connectiono from TLS.
type ListenerScanResult ¶ added in v0.0.38
type ListenerScanResult struct {
ActiveChannels []string `json:"active_channels"`
}
ListenerScanResult returns a snapshot of accessible channels at the moment.
type Option ¶
type Option struct { // TokenAuthority is the authority used for checking permissions. TokenAuthority Authority // DialConnectionTimeout specifies the timeout when a dialer connects to a listener. DialConnectionTimeout time.Duration // ListenConnectionKeepAlive specfies the health check interval. ListenConnectionKeepAlive time.Duration }
Option specifies a set of options being used by the router.
type PeerInfo ¶ added in v0.0.29
type PeerInfo struct { Name string `json:"name"` RemoteAddress string `json:"remote-address"` Expiration time.Time }
PeerInfo provides the necessary information to identify a peer.
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router proxies requests.
func NewDefaultRouter ¶
func NewDefaultRouter() *Router
NewDefaultRouter creates a router with default option.
type TrackerConnection ¶ added in v0.0.29
TrackerConnection keeps the track of the wrapped connection.
func (*TrackerConnection) Close ¶ added in v0.0.29
func (conn *TrackerConnection) Close() error
Close implements the net.Conn Close interface as well as finish the tracking.
func (*TrackerConnection) ErrorF ¶ added in v0.0.35
func (conn *TrackerConnection) ErrorF(format string, args ...interface{})
ErrorF prints a message to the according tracker and marks it as error status.
func (*TrackerConnection) PrintF ¶ added in v0.0.29
func (conn *TrackerConnection) PrintF(format string, args ...interface{})
PrintF prints a message to the according tracker.