Documentation
¶
Index ¶
- func RegisterURLHandler(schema string, uh URLHandler)
- type Channel
- func ChannelFromString(dest string, timeout time.Duration) (c Channel, err error)
- func ChannelFromURL(u *url.URL, timeout time.Duration) (c Channel, err error)
- func NewChannelFromSocket(connection net.Conn, timeout time.Duration) Channel
- func NewSocketChannel(proto, dest string, timeout time.Duration) (ch Channel, err error)
- func NewTCPChannel(dest *url.URL, timeout time.Duration) (ch Channel, err error)
- func NewUDPChannel(dest *url.URL, timeout time.Duration) (ch Channel, err error)
- type SocketChannel
- func (t *SocketChannel) Close() error
- func (t *SocketChannel) GetAllSubchannels() []Channel
- func (t *SocketChannel) LocalAddr() net.Addr
- func (*SocketChannel) NextBackend()
- func (s *SocketChannel) NumBackends() uint64
- func (t *SocketChannel) Read(p []byte) (n int, err error)
- func (t *SocketChannel) RemoteAddr() net.Addr
- func (s *SocketChannel) SetDeadline(t time.Time) error
- func (s *SocketChannel) SetReadDeadline(t time.Time) error
- func (s *SocketChannel) SetWriteDeadline(t time.Time) error
- func (*SocketChannel) WaitForNonEmpty(unused time.Duration) error
- func (t *SocketChannel) Write(p []byte) (n int, err error)
- type URLHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterURLHandler ¶
func RegisterURLHandler(schema string, uh URLHandler)
Register a given handler for the specified URL pattern.
Types ¶
type Channel ¶
type Channel interface {
net.Conn
// Delay until either we have at least 1 backend or until the deadline
// has expired. In case the deadline expires, an error is returned.
WaitForNonEmpty(deadline time.Duration) error
// Suggest to the channel to pick the next backend. This can be used
// for load balancing or other reasons. There's no guarantee that the
// backend will actually change though.
NextBackend()
// Total number of backends currently connected.
NumBackends() uint64
// List of all channels contained in this one. Can be useful to e.g.
// perform broadcast RPCs.
GetAllSubchannels() []Channel
}
Channels are essentially read/write/close interfaces with an additional option to force the channel to have at least one backend, and to switch to a different backend (which may or may not do something).
func ChannelFromString ¶
Connect to the destintation specified in "dest" (which should be an URL).
func ChannelFromURL ¶
Connect to the destination specified in "dest". A handler for the URL schema must be registered.
func NewChannelFromSocket ¶
Encapsulate the specified socket in a channel.
func NewSocketChannel ¶
Create a new socket channel for connecting to "dest". If "timeout" is greater than 0, set deadlines on all operations to the current time plus "timeout".
func NewTCPChannel ¶
Create a new TCP channel for connecting to "dest". If "timeout" is greater than 0, set deadlines on all operations to the current time plus "timeout".
type SocketChannel ¶
type SocketChannel struct {
// contains filtered or unexported fields
}
A TCP channel is a channel over a simple TCP connection with just one peer.
func (*SocketChannel) Close ¶
func (t *SocketChannel) Close() error
Closing a Socket channel closes the underlying Socket socket.
func (*SocketChannel) GetAllSubchannels ¶
func (t *SocketChannel) GetAllSubchannels() []Channel
Sockets only have a single backend, so the largest subset of channels making up this channel is this channel itself.
func (*SocketChannel) LocalAddr ¶
func (t *SocketChannel) LocalAddr() net.Addr
Local address is whatever the connection feels like.
func (*SocketChannel) NextBackend ¶
func (*SocketChannel) NextBackend()
On single-destination Socket connections, switching channels is a no-op.
func (*SocketChannel) NumBackends ¶
func (s *SocketChannel) NumBackends() uint64
Sockets only have a single backend.
func (*SocketChannel) Read ¶
func (t *SocketChannel) Read(p []byte) (n int, err error)
Reading from a Socket channel is basically just reading from the underlying Socket connection.
func (*SocketChannel) RemoteAddr ¶
func (t *SocketChannel) RemoteAddr() net.Addr
Remote address is whatever the connection thinks it is.
func (*SocketChannel) SetDeadline ¶
func (s *SocketChannel) SetDeadline(t time.Time) error
Set the deadline for reading and writing and stop automated deadline management.
func (*SocketChannel) SetReadDeadline ¶
func (s *SocketChannel) SetReadDeadline(t time.Time) error
Set the deadline for reading and stop automated deadline management.
func (*SocketChannel) SetWriteDeadline ¶
func (s *SocketChannel) SetWriteDeadline(t time.Time) error
Set the deadline for writing and stop automated deadline management.
func (*SocketChannel) WaitForNonEmpty ¶
func (*SocketChannel) WaitForNonEmpty(unused time.Duration) error
Socket channels are connected as soon as the constructor returns.