Documentation ¶
Index ¶
- Constants
- Variables
- func Encode(pack MessagePack) (bytes.Buffer, error)
- func StreamConn(stream grpc.Stream) *common.Conn
- type Conn
- func (c *Conn) Close() error
- func (c *Conn) LocalAddr() net.Addr
- func (c *Conn) Read(p []byte) (n int, err error)
- func (c *Conn) RemoteAddr() net.Addr
- func (c *Conn) SetDeadline(time.Time) error
- func (c *Conn) SetReadDeadline(time.Time) error
- func (c *Conn) SetWriteDeadline(time.Time) error
- func (c *Conn) Write(p []byte) (int, error)
- type GrpcServer
- type Handler
- type HttpServer
- type MessagePack
- type Options
- type Proto
- type Server
- type TcpServer
Constants ¶
const (
MaxMessageSize = 1 << 19
)
Variables ¶
var ErrServerClosed = errors.New("Server closed")
ErrServerClosed occurs when a tcp server is closed.
Functions ¶
Types ¶
type Conn ¶
type Conn struct { // Stream is the stream to wrap into a Conn. This is duplex stream. Stream *websocket.Conn // InMsg is the type to use for reading request data from the streaming // endpoint. This must be a non-nil allocated value and must NOT point to // the same value as OutMsg since they may be used concurrently. // // The Reset method will be called on InMsg during Reads so data you // set initially will be lost. InMsg proto.Message // OutMsg is the type to use for sending data to streaming endpoint. This must be // a non-nil allocated value and must NOT point to the same value as InMsg // since they may be used concurrently. // // The Reset method is never called on OutMsg so they will be sent for every request // unless the Encode field changes it. OutMsg proto.Message // WriteLock, if non-nil, will be locked while calling SendMsg // on the Stream. This can be used to prevent concurrent access to // SendMsg which is unsafe. WriteLock *sync.Mutex // Encode encodes messages into the Request. See Encoder for more information. Encode common.Encoder // Decode decodes messages from the Response into a byte slice. See // Decoder for more information. Decode common.Decoder // contains filtered or unexported fields }
Conn implements net.Conn across a Websocket.
Methods such as LocalAddr, RemoteAddr, deadlines, etc. do not work.
func WebSocketConn ¶
func (*Conn) Close ¶
Close will close the client if this is a client. If this is a server stream this does nothing since gRPC expects you to close the stream by returning from the RPC call.
This calls CloseSend underneath for clients, so read the documentation for that to understand the semantics of this call.
func (*Conn) SetDeadline ¶
SetDeadline is non-functional due to limitations on how gRPC works. You can mimic deadlines often using call options.
func (*Conn) SetReadDeadline ¶
SetReadDeadline is non-functional, see SetDeadline.
func (*Conn) SetWriteDeadline ¶
SetWriteDeadline is non-functional, see SetDeadline.
type GrpcServer ¶
type GrpcServer server
func NewGrpcServer ¶
func NewGrpcServer(opts ...Options) *GrpcServer
func (*GrpcServer) Stream ¶
func (s *GrpcServer) Stream(stream pbx.Unitdb_StreamServer) error
Stream implements duplex unitdb.Stream
type Handler ¶
Handler is a callback which get called when a tcp, websocket connection is established or a grpc stream is established
type HttpServer ¶
type HttpServer server
func NewHttpServer ¶
func NewHttpServer(opts ...Options) *HttpServer
func (*HttpServer) HandleFunc ¶
func (s *HttpServer) HandleFunc(w http.ResponseWriter, r *http.Request)
type MessagePack ¶ added in v0.2.0
type MessagePack interface { ToBinary() (bytes.Buffer, error) FromBinary(fh utp.FixedHeader, data []byte) Type() utp.MessageType Info() utp.Info }
MessagePack is the interface for all Messages
type Options ¶
type Options interface {
// contains filtered or unexported methods
}
Options it contains configurable options for client
func WithDefaultOptions ¶
func WithDefaultOptions() Options
WithDefaultOptions will create client connection with some default values.
KeepAlive: true TlsConfig: nil
func WithTLSConfig ¶
WithTLSConfig will set an SSL/TLS configuration to be used when connecting to server.