Documentation
¶
Index ¶
- func BaseContextStreamInterceptor(ctxInterceptor func(context.Context) context.Context) grpc.StreamServerInterceptor
- func BaseContextUnaryInterceptor(ctxInterceptor func(context.Context) context.Context) grpc.UnaryServerInterceptor
- func MarshalJSONAsAny(v any) (*anypb.Any, error)
- func SetEchoServersContext(ctx context.Context, server *grpc.Server, healthPing time.Duration)
- func UnmarshalJSONFromAny(anyValue *anypb.Any) (any, error)
- type CredentialsProvider
- type GcloudCredentialsProvider
- type LocalCredentialsProvider
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MarshalJSONAsAny ¶ added in v0.21.0
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
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
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)