grpcparser

package
v2.0.0-alpha56 Latest Latest
Warning

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

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

Documentation

Index

Constants

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

	KLabelForContentType = "content-type"
)
View Source
const (
	KmaxDynamicTableSize = 2048
)

Variables

This section is empty.

Functions

func CreateLengthPrefixedMessageFromPayload

func CreateLengthPrefixedMessageFromPayload(data []byte) models.GrpcLengthPrefixedMessage

func CreatePayloadFromLengthPrefixedMessage

func CreatePayloadFromLengthPrefixedMessage(msg models.GrpcLengthPrefixedMessage) ([]byte, error)

func ExtractHeaders

func ExtractHeaders(frame *http2.HeadersFrame, decoder *hpack.Decoder) (pseudoHeaders, ordinaryHeaders map[string]string, err error)

func FilterMocksBasedOnGrpcRequest

func FilterMocksBasedOnGrpcRequest(grpcReq models.GrpcReq, hook *hooks.Hook) (*models.Mock, error)

func FilterMocksRelatedToGrpc

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

func NewDecoder

func NewDecoder() *hpack.Decoder

func NewTranscoder

func NewTranscoder(framer *http2.Framer, logger *zap.Logger, h *hooks.Hook) *transcoder

func PrintDataFrame

func PrintDataFrame(frame *http2.DataFrame)

func PrintFrame

func PrintFrame(frame http2.Frame)

func PrintHeadersFrame

func PrintHeadersFrame(frame *http2.HeadersFrame)

func PrintPingFrame

func PrintPingFrame(frame *http2.PingFrame)

func PrintSettingsFrame

func PrintSettingsFrame(frame *http2.SettingsFrame)

func PrintWindowUpdateFrame

func PrintWindowUpdateFrame(frame *http2.WindowUpdateFrame)

func TransferFrame

func TransferFrame(lhs net.Conn, rhs net.Conn, sic *StreamInfoCollection, isReqFromClient bool, decoder *hpack.Decoder, ctx context.Context) error

TransferFrame reads one frame from rhs and writes it to lhs.

Types

type GrpcParser

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

func NewGrpcParser

func NewGrpcParser(logger *zap.Logger, h *hooks.Hook) *GrpcParser

func (*GrpcParser) OutgoingType

func (g *GrpcParser) OutgoingType(buffer []byte) bool

OutgoingType will be a method of GrpcParser.

func (*GrpcParser) ProcessOutgoing

func (g *GrpcParser) ProcessOutgoing(requestBuffer []byte, clientConn, destConn net.Conn, ctx context.Context)

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(h *hooks.Hook) *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(streamID uint32, ctx context.Context)

func (*StreamInfoCollection) ResetStream

func (sic *StreamInfoCollection) ResetStream(streamID uint32)

Jump to

Keyboard shortcuts

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