grpcdecode

package
v0.19.4 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2026 License: Apache-2.0, Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrEmptyReflectionTarget = errors.New("grpcdecode: empty reflection target")

ErrEmptyReflectionTarget is returned by FromReflection when an empty target string is supplied.

Functions

This section is empty.

Types

type Decoder

type Decoder interface {
	// Decode inspects reqBody/resBody (raw, length-prefixed gRPC message
	// envelopes) and populates ev.GRPC's request/response schemas and
	// Decoded flag when the method can be resolved against the decoder's
	// loaded descriptors. It never copies field values into ev; the
	// envelope payloads are parsed only to be discarded. A nil error is
	// returned even when nothing could be resolved (e.g. no descriptors
	// loaded, or the service/method isn't present in them) -- ev is simply
	// left unchanged in that case.
	Decode(reqBody, resBody []byte, ev *model.Event) error
}

Decoder decodes gRPC request/response messages using either descriptors or reflection. This implementation loads a FileDescriptorSet and derives JSON-like schemas for request/response messages. It does not expose raw values: Decode only ever populates structural schema information on ev.

func FromDescriptorsFile

func FromDescriptorsFile(path string) (Decoder, error)

FromDescriptorsFile reads a serialized descriptorpb.FileDescriptorSet from path (as produced by `protoc --descriptor_set_out`), parses it, and returns a Decoder that resolves gRPC service/method schemas against the messages and services it contains. It returns an error if the file cannot be read or fails to parse as a FileDescriptorSet.

func FromReflection

func FromReflection(target string) (Decoder, error)

FromReflection is optional; for now it returns a decoder that marks decoded=false if no descriptors are available. Hooking real reflection can be added later.

Jump to

Keyboard shortcuts

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