Documentation ¶
Overview ¶
Package grpc provides functionality for integrating with gRPC outgoing calls.
Index ¶
- Constants
- func FilterMocksBasedOnGrpcRequest(ctx context.Context, _ *zap.Logger, grpcReq models.GrpcReq, ...) (*models.Mock, error)
- func FilterMocksRelatedToGrpc(mocks []*models.Mock) []*models.Mock
- func NewDecoder() *hpack.Decoder
- func NewGrpc(logger *zap.Logger) integrations.Integrations
- type Grpc
- type StreamInfoCollection
- func (sic *StreamInfoCollection) AddHeadersForRequest(streamID uint32, headers map[string]string, isPseudo bool)
- func (sic *StreamInfoCollection) AddHeadersForResponse(streamID uint32, headers map[string]string, isPseudo, isTrailer bool)
- func (sic *StreamInfoCollection) AddPayloadForRequest(streamID uint32, payload []byte)
- func (sic *StreamInfoCollection) AddPayloadForResponse(streamID uint32, payload []byte)
- func (sic *StreamInfoCollection) FetchRequestForStream(streamID uint32) models.GrpcReq
- func (sic *StreamInfoCollection) InitialiseStream(streamID uint32)
- func (sic *StreamInfoCollection) PersistMockForStream(_ context.Context, streamID uint32, mocks chan<- *models.Mock)
- func (sic *StreamInfoCollection) ResetStream(streamID uint32)
- type Transcoder
- func (srv *Transcoder) ListenAndServe(ctx context.Context) error
- func (srv *Transcoder) ProcessContinuationFrame(_ *http2.ContinuationFrame) error
- func (srv *Transcoder) ProcessDataFrame(ctx context.Context, dataFrame *http2.DataFrame) error
- func (srv *Transcoder) ProcessGenericFrame(ctx context.Context, frame http2.Frame) error
- func (srv *Transcoder) ProcessGoAwayFrame(_ *http2.GoAwayFrame) error
- func (srv *Transcoder) ProcessHeadersFrame(headersFrame *http2.HeadersFrame) error
- func (srv *Transcoder) ProcessPingFrame(pingFrame *http2.PingFrame) error
- func (srv *Transcoder) ProcessPriorityFrame(_ *http2.PriorityFrame) error
- func (srv *Transcoder) ProcessPushPromise(_ *http2.PushPromiseFrame) error
- func (srv *Transcoder) ProcessResetStreamFrame(resetStreamFrame *http2.RSTStreamFrame) error
- func (srv *Transcoder) ProcessSettingsFrame(settingsFrame *http2.SettingsFrame) error
- func (srv *Transcoder) ProcessWindowUpdateFrame(_ *http2.WindowUpdateFrame) error
- func (srv *Transcoder) WriteInitialSettingsFrame() error
Constants ¶
const ( KLabelForAuthority = ":authority" KLabelForMethod = ":method" KLabelForPath = ":path" KLabelForScheme = ":http" KLabelForContentType = "content-type" )
constants for the pseudo headers.
const (
KmaxDynamicTableSize = 2048
)
constants for dynamic table size
Variables ¶
This section is empty.
Functions ¶
func NewGrpc ¶
func NewGrpc(logger *zap.Logger) integrations.Integrations
Types ¶
type Grpc ¶
type Grpc struct {
// contains filtered or unexported fields
}
func (*Grpc) MatchType ¶
MatchType function determines if the outgoing network call is gRPC by comparing the message format with that of an gRPC text message.
func (*Grpc) MockOutgoing ¶
func (g *Grpc) MockOutgoing(ctx context.Context, src net.Conn, dstCfg *integrations.ConditionalDstCfg, mockDb integrations.MockMemDb, opts models.OutgoingOptions) error
type StreamInfoCollection ¶
type StreamInfoCollection struct { StreamInfo map[uint32]models.GrpcStream ReqTimestampMock time.Time ResTimestampMock time.Time // contains filtered or unexported fields }
StreamInfoCollection is a thread-safe data structure to store all communications that happen in a stream for grpc. This includes the headers and data frame for the request and response.
func NewStreamInfoCollection ¶
func NewStreamInfoCollection() *StreamInfoCollection
func (*StreamInfoCollection) AddHeadersForRequest ¶
func (sic *StreamInfoCollection) AddHeadersForRequest(streamID uint32, headers map[string]string, isPseudo bool)
func (*StreamInfoCollection) AddHeadersForResponse ¶
func (sic *StreamInfoCollection) AddHeadersForResponse(streamID uint32, headers map[string]string, isPseudo, isTrailer bool)
func (*StreamInfoCollection) AddPayloadForRequest ¶
func (sic *StreamInfoCollection) AddPayloadForRequest(streamID uint32, payload []byte)
AddPayloadForRequest adds the DATA frame to the stream. A data frame always appears after at least one header frame. Hence, we implicitly assume that the stream has been initialised.
func (*StreamInfoCollection) AddPayloadForResponse ¶
func (sic *StreamInfoCollection) AddPayloadForResponse(streamID uint32, payload []byte)
AddPayloadForResponse adds the DATA frame to the stream. A data frame always appears after at least one header frame. Hence, we implicitly assume that the stream has been initialised.
func (*StreamInfoCollection) FetchRequestForStream ¶
func (sic *StreamInfoCollection) FetchRequestForStream(streamID uint32) models.GrpcReq
func (*StreamInfoCollection) InitialiseStream ¶
func (sic *StreamInfoCollection) InitialiseStream(streamID uint32)
func (*StreamInfoCollection) PersistMockForStream ¶
func (*StreamInfoCollection) ResetStream ¶
func (sic *StreamInfoCollection) ResetStream(streamID uint32)
type Transcoder ¶
type Transcoder struct {
// contains filtered or unexported fields
}
func NewTranscoder ¶
func NewTranscoder(logger *zap.Logger, framer *http2.Framer, mockDb integrations.MockMemDb) *Transcoder
func (*Transcoder) ListenAndServe ¶
func (srv *Transcoder) ListenAndServe(ctx context.Context) error
ListenAndServe is a forever blocking call that reads one frame at a time, and responds to them.
func (*Transcoder) ProcessContinuationFrame ¶
func (srv *Transcoder) ProcessContinuationFrame(_ *http2.ContinuationFrame) error
func (*Transcoder) ProcessDataFrame ¶
func (*Transcoder) ProcessGenericFrame ¶
func (*Transcoder) ProcessGoAwayFrame ¶
func (srv *Transcoder) ProcessGoAwayFrame(_ *http2.GoAwayFrame) error
func (*Transcoder) ProcessHeadersFrame ¶
func (srv *Transcoder) ProcessHeadersFrame(headersFrame *http2.HeadersFrame) error
func (*Transcoder) ProcessPingFrame ¶
func (srv *Transcoder) ProcessPingFrame(pingFrame *http2.PingFrame) error
func (*Transcoder) ProcessPriorityFrame ¶
func (srv *Transcoder) ProcessPriorityFrame(_ *http2.PriorityFrame) error
func (*Transcoder) ProcessPushPromise ¶
func (srv *Transcoder) ProcessPushPromise(_ *http2.PushPromiseFrame) error
func (*Transcoder) ProcessResetStreamFrame ¶
func (srv *Transcoder) ProcessResetStreamFrame(resetStreamFrame *http2.RSTStreamFrame) error
func (*Transcoder) ProcessSettingsFrame ¶
func (srv *Transcoder) ProcessSettingsFrame(settingsFrame *http2.SettingsFrame) error
func (*Transcoder) ProcessWindowUpdateFrame ¶
func (srv *Transcoder) ProcessWindowUpdateFrame(_ *http2.WindowUpdateFrame) error
func (*Transcoder) WriteInitialSettingsFrame ¶
func (srv *Transcoder) WriteInitialSettingsFrame() error