grpc

package
v2.2.0-alpha21-rc2 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package grpc provides functionality for integrating with gRPC outgoing calls.

Index

Constants

View Source
const (
	KLabelForAuthority = ":authority"
	KLabelForMethod    = ":method"
	KLabelForPath      = ":path"
	KLabelForScheme    = ":http"

	KLabelForContentType = "content-type"
)

constants for the pseudo headers.

View Source
const (
	KmaxDynamicTableSize = 2048
)

constants for dynamic table size

Variables

This section is empty.

Functions

func FilterMocksBasedOnGrpcRequest

func FilterMocksBasedOnGrpcRequest(ctx context.Context, _ *zap.Logger, grpcReq models.GrpcReq, mockDb integrations.MockMemDb) (*models.Mock, error)

func FilterMocksRelatedToGrpc

func FilterMocksRelatedToGrpc(mocks []*models.Mock) []*models.Mock

func NewDecoder

func NewDecoder() *hpack.Decoder

NewDecoder returns a header decoder.

func NewGrpc

func NewGrpc(logger *zap.Logger) integrations.Integrations

Types

type Grpc

type Grpc struct {
	// contains filtered or unexported fields
}

func (*Grpc) MatchType

func (g *Grpc) MatchType(_ context.Context, reqBuf []byte) bool

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

func (*Grpc) RecordOutgoing

func (g *Grpc) RecordOutgoing(ctx context.Context, src net.Conn, dst net.Conn, mocks chan<- *models.Mock, 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 (sic *StreamInfoCollection) PersistMockForStream(_ context.Context, streamID uint32, mocks chan<- *models.Mock)

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 (srv *Transcoder) ProcessDataFrame(ctx context.Context, dataFrame *http2.DataFrame) error

func (*Transcoder) ProcessGenericFrame

func (srv *Transcoder) ProcessGenericFrame(ctx context.Context, frame http2.Frame) error

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

Jump to

Keyboard shortcuts

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