grpcf

package
v0.22.2 Latest Latest
Warning

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

Go to latest
Published: May 22, 2026 License: MIT Imports: 17 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BaseContextStreamInterceptor

func BaseContextStreamInterceptor(
	ctxInterceptor func(context.Context) context.Context,
) grpc.StreamServerInterceptor

func BaseContextUnaryInterceptor

func BaseContextUnaryInterceptor(
	ctxInterceptor func(context.Context) context.Context,
) grpc.UnaryServerInterceptor

func MarshalJSONAsAny added in v0.21.0

func MarshalJSONAsAny(v any) (*anypb.Any, error)

MarshalJSONAsAny serialises an arbitrary Go value to JSON and packs the resulting bytes into a google.protobuf.Any whose contained message type is google.protobuf.BytesValue. Use it only when an RPC field is typed as Any and you actually want to carry an opaque JSON payload — Any is normally reserved for genuine protobuf messages, so this is a deliberate escape hatch, not the default way to transit data.

The inverse is UnmarshalJSONFromAny.

func SetEchoServersContext added in v0.21.0

func SetEchoServersContext(ctx context.Context, server *grpc.Server, healthPing time.Duration)

SetEchoServersContext registers the built-in echo + health-check services on the given gRPC server and starts a background goroutine that toggles the SERVING/NOT_SERVING status every healthPing tick. The goroutine returns when ctx is canceled, so the caller can tie its lifetime to graceful shutdown.

A non-positive healthPing degrades to a tight toggle loop that still honours ctx cancellation — `time.NewTicker` would panic on a zero or negative duration, so the wait is built around `time.After` instead.

func UnmarshalJSONFromAny added in v0.21.0

func UnmarshalJSONFromAny(anyValue *anypb.Any) (any, error)

UnmarshalJSONFromAny is the inverse of MarshalJSONAsAny: it extracts the JSON payload from a google.protobuf.Any (assumed to wrap a google.protobuf.BytesValue) and decodes it into an `any` Go value.

Types

type CredentialsProvider

type CredentialsProvider interface {
	Options(ctx context.Context) ([]grpc.DialOption, error)
}

type GcloudCredentialsProvider

type GcloudCredentialsProvider struct {
	Host string
}

func (*GcloudCredentialsProvider) Options

func (provider *GcloudCredentialsProvider) Options(ctx context.Context) ([]grpc.DialOption, error)

type LocalCredentialsProvider

type LocalCredentialsProvider struct{}

func (*LocalCredentialsProvider) Options

func (provider *LocalCredentialsProvider) Options(_ context.Context) ([]grpc.DialOption, error)

Directories

Path Synopsis
proto
gen

Jump to

Keyboard shortcuts

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