Documentation ¶
Index ¶
- Constants
- Variables
- type Client
- type ClientOption
- type Codec
- type Conn
- type EventHandler
- type JsonCodec
- type Pool
- type ProtoCodec
- type ProxyHandler
- type Serve
- func (s *Serve) GetConnByID(id string) *Conn
- func (s *Serve) GetConnsByID(id string) []*Conn
- func (s *Serve) HandleProxy(w http.ResponseWriter, r *http.Request)
- func (s *Serve) HandleProxyWithRetry(w http.ResponseWriter, r *http.Request)
- func (s *Serve) HandleWS(w http.ResponseWriter, r *http.Request)
- type ServeOption
Constants ¶
View Source
const HeaderClientId = "x-backstream-client-id"
Variables ¶
View Source
var ErrConnectionClosed = errors.New("connection closed")
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
type ClientOption ¶
type ClientOption func(*Client)
func WithClientID ¶
func WithClientID(clientID string) ClientOption
func WithClientLogger ¶
func WithClientLogger(logger *slog.Logger) ClientOption
func WithClientTLSConfigFunc ¶ added in v0.0.2
func WithClientTLSConfigFunc(tlsConfigFunc func() *tls.Config) ClientOption
type Codec ¶
type Codec[T proto.Message] interface { Encode(t T) ([]byte, error) Decode(data []byte, t T) error // IsBinary determines is message is text or binary data message. IsBinary() bool }
func NewJsonCodec ¶
func NewProtoCodec ¶
type EventHandler ¶
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
func (*Pool) GetConnByID ¶
func (*Pool) GetConnsByID ¶
type ProtoCodec ¶
func (ProtoCodec[T]) Decode ¶
func (c ProtoCodec[T]) Decode(data []byte, t T) error
func (ProtoCodec[T]) Encode ¶
func (c ProtoCodec[T]) Encode(v T) ([]byte, error)
func (ProtoCodec[T]) IsBinary ¶
func (c ProtoCodec[T]) IsBinary() bool
type ProxyHandler ¶
type ProxyHandler interface { EventHandler ProxyRequest(conn *Conn, w http.ResponseWriter, r *http.Request) error }
type Serve ¶
type Serve struct {
// contains filtered or unexported fields
}
func NewServe ¶
func NewServe(parent context.Context, handler ProxyHandler, codec Codec[*message.Message], opts ...ServeOption) *Serve
func (*Serve) GetConnByID ¶
func (*Serve) GetConnsByID ¶
func (*Serve) HandleProxy ¶
func (s *Serve) HandleProxy(w http.ResponseWriter, r *http.Request)
func (*Serve) HandleProxyWithRetry ¶
func (s *Serve) HandleProxyWithRetry(w http.ResponseWriter, r *http.Request)
type ServeOption ¶
type ServeOption func(*Serve)
func WithRequireClientId ¶
func WithRequireClientId(b bool) ServeOption
func WithServeLogger ¶
func WithServeLogger(logger *slog.Logger) ServeOption
Click to show internal directories.
Click to hide internal directories.