dynamic

package
v0.14.4 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClusterFromString

func ClusterFromString(ctx context.Context, s string) (c *cluster.Cluster, id string, err error)

ClusterFromString returns a cluster ID and possibly fully-usable Cluster from a base64-encoded JSON spec.

If an error occurs decoding or unmarshalling the string, this function returns, respectively, the empty string, a nil Cluster, and a non-nil error.

If the string can be decoded and unmarshalled, then the id will be non-empty, but errors may still be returned from instantiating the cluster, for example if the configuration in the JSON spec is invalid.

Therefore, callers should handle the return values as follows:

c, id, err := dynamic.ClusterFromString(ctx, s)
if id == "" {
	// handle err, do not use `c`.
}
if err != nil {
	// log error. if desired, lookup the existing cluster with ID: `id`
}
// Use `c` (or existing cluster with ID == `id`) based on the dynamic cluster
api.WithCluster(c, id).DoAThing()

func StreamServerInterceptor

func StreamServerInterceptor(api API) grpc.StreamServerInterceptor

StreamServerInterceptor returns a StreamServerInterceptor that redirects a streaming RPC to a dynamic API if the incoming context has a cluster spec in its metadata. Otherwise, the interceptor is a no-op, and the original stream handler is invoked.

func UnaryServerInterceptor

func UnaryServerInterceptor(api API) grpc.UnaryServerInterceptor

UnaryServerInterceptor returns a UnaryServerInterceptor that redirects a unary RPC to a dynamic API if the incoming context has a cluster spec in its metadata. Otherwise, the interceptor is a no-op, and the original method handler is invoked.

Types

type API

type API interface {
	vtadminpb.VTAdminServer
	WithCluster(c *cluster.Cluster, id string) API
	Handler() http.Handler
}

API is the interface dynamic APIs must implement. It is implemented by vtadmin.API.

Jump to

Keyboard shortcuts

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