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 // DefaultServerBufferBytes is the default buffer size to exchange between connections. DefaultServerBufferBytes = 4096 )
const MaxChannelNameLength = 256
MaxChannelNameLength limits the maxmimum length of a channel name.
Variables ¶
var DefaultRouterOption = Option{ TokenAuthority: &noPermissionCheckAuthority{}, DialConnectionTimeout: DefaultDialConnectionTimeout, ListenConnectionKeepAlive: DefaultListenConnectionKeepAlive, ChannelBufferBytes: DefaultServerBufferBytes, }
DefaultRouterOption is a set of parameters in default value.
Functions ¶
func DialOnConn ¶ added in v0.0.22
DialOnConn initiaites a dial protocol with the router on `RouterAddress`. It is caller's resposibility to close the connection on error.
Types ¶
type Address ¶
type Address struct {
Channel string
}
Address represents an address in Router network.
type Authority ¶
type Authority interface { // Returns if the permission check is passed for `frame`. CheckPermission(*Frame, net.Conn) error // Returns the expiration time of the key. Router will use this to set a connection deadline. GetExpirationTime(*Frame, net.Conn) time.Time }
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.
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 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 // ChannelBufferBytes specifies the size of the buffer while bridging the channel. ChannelBufferBytes uint64 }
Option specifies a set of options being used by the router.
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.