rpcz

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2024 License: BSD-2-Clause Imports: 19 Imported by: 6

README

rpcz

GoDoc

This library shows recent gRPC calls on a web page including their payloads for debugging.

You need to register interceptors for every gRPC client and server that you want to debug.

// Servers
s := grpc.NewServer(grpc.ChainUnaryInterceptor(UnaryServerInterceptor), grpc.ChainStreamInterceptor(StreamServerInterceptor))

// Clients
c, err := grpc.Dial(addr, grpc.WithUnaryInterceptor(rpcz.UnaryClientInterceptor), grpc.WithStreamInterceptor(rpcz.StreamClientInterceptor))

// Expose the debugging page. Make sure to protect it appropriately, as it exposes all RPC payloads.
http.Handle("/rpcz", httpauth.SimpleBasicAuth("debugger", "hackme")(rpcz.Handler))

Allow me to reiterate: It is very important to protect the rpcz.Handler against unprivileged access if you don't want a data leak.

Screenshot

Documentation

Index

Constants

View Source
const (
	KeepFirstNStreamingMessages = 5
	KeepLastNStreamingMessages  = 5
)

Variables

View Source
var (
	// SamplingRate is the chance it samples the message.
	SamplingRate        = 1.0
	RetainRPCsPerMethod = 10
	RecordMetadata      = true
)
View Source
var Handler http.Handler = convreq.Wrap(handler)

Functions

func StreamClientInterceptor added in v0.2.0

func StreamClientInterceptor(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, streamer grpc.Streamer, opts ...grpc.CallOption) (grpc.ClientStream, error)

func StreamServerInterceptor added in v0.2.0

func StreamServerInterceptor(srv interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error

func UnaryClientInterceptor

func UnaryClientInterceptor(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error

func UnaryServerInterceptor

func UnaryServerInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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