Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrBridgeContextCanceled indicates the bridge was shut down due to context cancellation // This typically happens during graceful shutdown or when the gateway context is canceled ErrBridgeContextCanceled = errors.New("bridge context canceled") // ErrBridgeMessageProcessingFailed indicates the bridge was shut down due to message processing errors // This includes protocol errors, QoS validation failures, or message transformation failures ErrBridgeMessageProcessingFailed = errors.New("bridge message processing failed") // ErrBridgeConnectionFailed indicates the bridge was shut down due to connection-level failures // This includes write failures, connection drops, or network-level errors ErrBridgeConnectionFailed = errors.New("bridge connection failed") // This includes endpoint disconnections or endpoint-side errors ErrBridgeEndpointUnavailable = errors.New("bridge endpoint unavailable") )
Bridge shutdown error types used to determine appropriate Websocket close codes
Functions ¶
func ConnectWebsocketEndpoint ¶
func ConnectWebsocketEndpoint( wsLogger polylog.Logger, websocketURL string, headers http.Header, ) (*websocket.Conn, error)
ConnectWebsocketEndpoint makes a websocket connection to the websocket Endpoint.
func StartBridge ¶
func StartBridge( ctx context.Context, logger polylog.Logger, req *http.Request, w http.ResponseWriter, websocketURL string, headers http.Header, websocketMessageProcessor WebsocketMessageProcessor, messageObservationsChan chan *observation.RequestResponseObservations, ) (<-chan struct{}, error)
StartBridge creates a new Bridge instance with connections to both client and endpoint and starts the bridge. Returns a channel that will be closed when the bridge shuts down.
Types ¶
type WebsocketMessageProcessor ¶
type WebsocketMessageProcessor interface {
// ProcessClientWebsocketMessage processes a message from the client.
ProcessClientWebsocketMessage([]byte) ([]byte, error)
// ProcessEndpointWebsocketMessage processes a message from the endpoint.
ProcessEndpointWebsocketMessage([]byte) ([]byte, *observation.RequestResponseObservations, error)
}
A WebsocketMessageProcessor processes websocket messages. For example, the Gateway package's websocketRequestContext implements this interface. It then, in turn, performs both protocol-level and QoS-level message processing on the message data
Click to show internal directories.
Click to hide internal directories.