Documentation
¶
Overview ¶
Package gossiphttp implements an HTTP/2 transport for gossip.
Protocol ¶
Peers send two types of messages to each other:
/api/v1/ckit/transport/message sends a stream of messages to a peer. The receiver does not respond with any messages.
/api/v1/ckit/transport/stream opens a bidirectional communication channel to a peer, where both peers may send messages to each other. Once either peer closes the connection, the stream is terminated.
Both requests expect the Content-Type header to be set to application/x.ckit.
Requests MUST be delivered over HTTP/2. HTTP/1.X requests will be rejected with HTTP 505 HTTP Version Not Supported.
Message Format ¶
All messages sent between peers have the same format:
+------------------------+ | Magic = 0xCC <1 byte> | |------------------------| | Data length <2 bytes> | |------------------------| | Data <n bytes> | +------------------------+
It is recommended that the message data size kept within the UDP MTU size, normally 1400 bytes. The message data size must not exeed 65,535 bytes.
Index ¶
- type Options
- type Transport
- func (t *Transport) DialAddressTimeout(addr memberlist.Address, timeout time.Duration) (net.Conn, error)
- func (t *Transport) DialTimeout(addr string, timeout time.Duration) (net.Conn, error)
- func (t *Transport) FinalAdvertiseAddr(ip string, port int) (net.IP, int, error)
- func (t *Transport) Handler() (route string, handler http.Handler)
- func (t *Transport) PacketCh() <-chan *memberlist.Packet
- func (t *Transport) Shutdown() error
- func (t *Transport) StreamCh() <-chan net.Conn
- func (t *Transport) WriteTo(b []byte, addr string) (time.Time, error)
- func (t *Transport) WriteToAddress(b []byte, addr memberlist.Address) (time.Time, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Options ¶
type Options struct { // Optional logger to use. Log log.Logger // Client to use for communicating to peers. Required. The Transport used // by the client must be able to handle HTTP/2 requests for any peer. // // Note that TLS is not required for communication between peers. The // Client.Transport should be able to fall back to h2c for HTTP/2 traffic // when connections over HTTPS are not used. Client *http.Client // Timeout to use when sending a packet. PacketTimeout time.Duration // UseHTTPS defines whether TLS should be used for communication between // peers. UseHTTPS bool }
Options controls the gossiphttp transport.
type Transport ¶
type Transport struct {
// contains filtered or unexported fields
}
Transport is an HTTP/2 implementation of memberlist.Transport. Call NewTransport to create one.
func NewTransport ¶
func NewTransport(opts Options) (*Transport, prometheus.Collector, error)
NewTransport returns a new Transport. Transports must be attached to an HTTP server so their endpoints are invoked. See [Handler] for more information.
func (*Transport) DialAddressTimeout ¶
func (t *Transport) DialAddressTimeout(addr memberlist.Address, timeout time.Duration) (net.Conn, error)
DialAddressTimeout implements NodeAwareTransport.
func (*Transport) DialTimeout ¶
DialTimeout opens a bidirectional communication channel to the specified peer address.
func (*Transport) FinalAdvertiseAddr ¶
FinalAdvertiseAddr returns the address this peer uses to advertise its connections.
func (*Transport) PacketCh ¶
func (t *Transport) PacketCh() <-chan *memberlist.Packet
PacketCh returns a channel of packets received from remote peers.
func (*Transport) StreamCh ¶
StreamCh returns a channel of bidirectional communication channels opened by remote peers.
func (*Transport) WriteTo ¶
WriteTo enqueues a message b to be sent to the peer specified by addr. The message is delivered in the background asynchronously by the transport.
func (*Transport) WriteToAddress ¶
WriteToAddress implements NodeAwareTransport.