Documentation ¶
Index ¶
- Constants
- type TMultiUDPTransport
- func (p *TMultiUDPTransport) Close() error
- func (p *TMultiUDPTransport) Flush() error
- func (p *TMultiUDPTransport) IsOpen() bool
- func (p *TMultiUDPTransport) Open() error
- func (p *TMultiUDPTransport) Read(buf []byte) (int, error)
- func (p *TMultiUDPTransport) RemainingBytes() uint64
- func (p *TMultiUDPTransport) Write(buff []byte) (int, error)
- type TUDPTransport
- func (p *TUDPTransport) Addr() net.Addr
- func (p *TUDPTransport) Close() error
- func (p *TUDPTransport) Conn() *net.UDPConn
- func (p *TUDPTransport) Flush() error
- func (p *TUDPTransport) IsOpen() bool
- func (p *TUDPTransport) Open() error
- func (p *TUDPTransport) Read(buf []byte) (int, error)
- func (p *TUDPTransport) ReadByte() (byte, error)
- func (p *TUDPTransport) RemainingBytes() uint64
- func (p *TUDPTransport) Write(buf []byte) (int, error)
- func (p *TUDPTransport) WriteByte(b byte) error
- func (p *TUDPTransport) WriteString(s string) (int, error)
Constants ¶
const MaxLength = 65000
MaxLength of UDP packet
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type TMultiUDPTransport ¶
type TMultiUDPTransport struct {
// contains filtered or unexported fields
}
TMultiUDPTransport does multiUDP as a thrift.TTransport
func NewTMultiUDPClientTransport ¶
func NewTMultiUDPClientTransport( destHostPorts []string, locHostPort string, ) (*TMultiUDPTransport, error)
NewTMultiUDPClientTransport creates a set of net.UDPConn-backed TTransports for Thrift clients All writes are buffered and flushed in one UDP packet. If locHostPort is not "", it will be used as the local address for the connection Example:
trans, err := thriftudp.NewTMultiUDPClientTransport([]string{"192.168.1.1:9090","192.168.1.2:9090"}, "")
func (*TMultiUDPTransport) Close ¶
func (p *TMultiUDPTransport) Close() error
Close closes the connections of the underlying transports
func (*TMultiUDPTransport) Flush ¶
func (p *TMultiUDPTransport) Flush() error
Flush flushes the write buffer of the underlying transports
func (*TMultiUDPTransport) IsOpen ¶
func (p *TMultiUDPTransport) IsOpen() bool
IsOpen returns true if the connections of the underlying transports are open
func (*TMultiUDPTransport) Open ¶
func (p *TMultiUDPTransport) Open() error
Open the connections of the underlying transports
func (*TMultiUDPTransport) Read ¶
func (p *TMultiUDPTransport) Read(buf []byte) (int, error)
Read is not supported for multiple underlying transports
func (*TMultiUDPTransport) RemainingBytes ¶
func (p *TMultiUDPTransport) RemainingBytes() uint64
RemainingBytes is not supported for multiple underlying transports
type TUDPTransport ¶
type TUDPTransport struct {
// contains filtered or unexported fields
}
TUDPTransport does UDP as a thrift.TTransport
func NewTUDPClientTransport ¶
func NewTUDPClientTransport(destHostPort string, locHostPort string) (*TUDPTransport, error)
NewTUDPClientTransport creates a net.UDPConn-backed TTransport for Thrift clients All writes are buffered and flushed in one UDP packet. If locHostPort is not "", it will be used as the local address for the connection Example:
trans, err := thriftudp.NewTUDPClientTransport("192.168.1.1:9090", "")
func NewTUDPServerTransport ¶
func NewTUDPServerTransport(hostPort string) (*TUDPTransport, error)
NewTUDPServerTransport creates a net.UDPConn-backed TTransport for Thrift servers It will listen for incoming udp packets on the specified host/port Example:
trans, err := thriftudp.NewTUDPClientTransport("localhost:9001")
func NewTUDPServerTransportWithListenConfig ¶
func NewTUDPServerTransportWithListenConfig( hostPort string, listenConfig net.ListenConfig, ) (*TUDPTransport, error)
NewTUDPServerTransportWithListenConfig creates a net.UDPConn-backed TTransport for Thrift servers It will listen for incoming udp packets on the specified host/port It takes net.ListenConfig to customize socket options
func (*TUDPTransport) Addr ¶
func (p *TUDPTransport) Addr() net.Addr
Addr returns the address that the transport is listening on or writing to
func (*TUDPTransport) Close ¶
func (p *TUDPTransport) Close() error
Close closes the transport and the underlying connection. Note: the current implementation allows Close to be called multiple times without an error.
func (*TUDPTransport) Conn ¶
func (p *TUDPTransport) Conn() *net.UDPConn
Conn retrieves the underlying net.UDPConn
func (*TUDPTransport) Flush ¶
func (p *TUDPTransport) Flush() error
Flush flushes the write buffer as one udp packet
func (*TUDPTransport) IsOpen ¶
func (p *TUDPTransport) IsOpen() bool
IsOpen returns true if the connection is open
func (*TUDPTransport) Open ¶
func (p *TUDPTransport) Open() error
Open does nothing as connection is opened on creation Required to maintain thrift.TTransport interface
func (*TUDPTransport) Read ¶
func (p *TUDPTransport) Read(buf []byte) (int, error)
Read reads one UDP packet and puts it in the specified buf
func (*TUDPTransport) ReadByte ¶
func (p *TUDPTransport) ReadByte() (byte, error)
ReadByte reads a single byte and returns it
func (*TUDPTransport) RemainingBytes ¶
func (p *TUDPTransport) RemainingBytes() uint64
RemainingBytes returns the max number of bytes (same as Thrift's StreamTransport) as we do not know how many bytes we have left.
func (*TUDPTransport) Write ¶
func (p *TUDPTransport) Write(buf []byte) (int, error)
Write writes specified buf to the write buffer
func (*TUDPTransport) WriteByte ¶
func (p *TUDPTransport) WriteByte(b byte) error
WriteByte writes a single byte to the write buffer
func (*TUDPTransport) WriteString ¶
func (p *TUDPTransport) WriteString(s string) (int, error)
WriteString writes the specified string to the write buffer