gateway

package
v1.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 18, 2023 License: MIT Imports: 13 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

Functions

func New

func ProtoErrorHandler

func ProtoErrorHandler(ctx context.Context, mux *runtime.ServeMux, marshaler runtime.Marshaler,
	w http.ResponseWriter, r *http.Request, err error)

func StreamErrorHandler

func StreamErrorHandler(ctx context.Context, err error) *runtime.StreamError

func URLQueryMetadata

func URLQueryMetadata(_ context.Context, r *http.Request) metadata.MD

Types

type WebStream added in v1.0.0

type WebStream struct {
	*websocket.Conn
	// contains filtered or unexported fields
}

WebStream implements grpc.ServerStream for websocket connection.

func NewWebsocketStream added in v1.0.0

func NewWebsocketStream(ctx context.Context, c *websocket.Conn, in, out runtime.Marshaler) *WebStream

func (*WebStream) Context added in v1.0.0

func (ws *WebStream) Context() context.Context

Context returns the context for this stream.

func (*WebStream) RecvMsg added in v1.0.0

func (ws *WebStream) RecvMsg(m interface{}) error

RecvMsg blocks until it receives a message into m or the stream is done. It returns io.EOF when the client has performed a CloseSend. On any non-EOF error, the stream is aborted and the error contains the RPC status.

It is safe to have a goroutine calling SendMsg and another goroutine calling RecvMsg on the same stream at the same time, but it is not safe to call RecvMsg on the same stream in different goroutines.

func (*WebStream) SendHeader added in v1.0.0

func (ws *WebStream) SendHeader(metadata.MD) error

SendHeader sends the header metadata. The provided md and headers set by SetHeader() will be sent. It fails if called multiple times.

func (*WebStream) SendMsg added in v1.0.0

func (ws *WebStream) SendMsg(m interface{}) error

SendMsg sends a message. On error, SendMsg aborts the stream and the error is returned directly.

SendMsg blocks until:

  • There is sufficient flow control to schedule m with the transport, or
  • The stream is done, or
  • The stream breaks.

SendMsg does not wait until the message is received by the client. An untimely stream closure may result in lost messages.

It is safe to have a goroutine calling SendMsg and another goroutine calling RecvMsg on the same stream at the same time, but it is not safe to call SendMsg on the same stream in different goroutines.

func (*WebStream) SetHeader added in v1.0.0

func (ws *WebStream) SetHeader(metadata.MD) error

SetHeader sets the header metadata. It may be called multiple times. When call multiple times, all the provided metadata will be merged. All the metadata will be sent out when one of the following happens:

  • ServerStream.SendHeader() is called;
  • The first response is sent out;
  • An RPC status is sent out (error or success).

func (*WebStream) SetTrailer added in v1.0.0

func (ws *WebStream) SetTrailer(metadata.MD)

SetTrailer sets the trailer metadata which will be sent with the RPC status. When called more than once, all the provided metadata will be merged.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL