Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CanonicalRPCName ¶
func CanonicalRPCName(svcName protoreflect.FullName, methodName protoreflect.Name) string
CanonicalRPCName returns the canonical gRPC method name, as specified in the gRPC PROTOCOL-HTTP2 spec.
Types ¶
type Binding ¶
type Binding struct { HTTPMethod string Pattern string RequestBodyPath string ResponseBodyPath string }
func DefaultBinding ¶
type FileResolver ¶
FileResolver contains basic methods needed to discover proto files by their name and defined symbols. It is used for implementing gRPC reflection and by ParseTarget for parsing Target definitions.
type Message ¶
func ConcreteMessage ¶
ConcreteMessage returns a Message implementation which simply allocates the concrete proto.Message implementation on each New call.
func DynamicMessage ¶
func DynamicMessage(desc protoreflect.MessageDescriptor) Message
DynamicMessage returns a Message implementation which uses dynamicpb.NewMessage to dynamically create messages based on a protoreflect.MessageDescriptor.
type Method ¶
type Method struct { RPCName string Input Message Output Message ClientStreaming bool ServerStreaming bool Bindings []Binding }
func DummyMethod ¶
func DummyMethod(svcName protoreflect.FullName, methodName protoreflect.Name) *Method
DummyMethod constructs a dummy method description containing emptypb.Empty messages as Input and Output. Proto properly unmarshals any message into an empty one, keeping all the fields as protoimpl.UnknownFields, so this can be used for unmarshaling/marshaling proto messages without needing to know their complete definitions, Useful for cases such as barebones gRPC proxying and gRPC-Web bridging.
type Service ¶
type Service struct { Name protoreflect.FullName Methods []Method }
type Target ¶
type Target struct { // A target's name is arbitrary and only makes sense in the context of grpcbridge. Name string // FileRegistry is the resolver of proto files defined for this target, using which the description was parsed. FileResolver FileResolver // TypeRegistry is the resolver of proto type descriptors defined for this target, it should be derived from the FileRegistry. TypeResolver TypeResolver // Services contain the descriptions of services available in this target. // Note that the FileRegistry might define more services to be available in the files, // however, this list contains only the services that are actually served by the target. // The list of services isn't required to contain full descriptions of all service methods, // and can simply contain the names on the services, // in which case it would still be usable for cases like gRPC proxying and gRPC-Web bridging. Services []Service }
func ParseTarget ¶
func ParseTarget(name string, files FileResolver, types TypeResolver, svcNames []protoreflect.FullName) *Target
ParseTarget parses the complete description of a target using the specified registries, and sets the target's name.
A target description without services doesn't make sense in the context of grpcbridge, because the file registry might contain an arbitrary number of services which aren't actually served by the target itself. For example, a target's service can depend on health.proto, but not be actually running the base gRPC healthcheck service. For this reason, the services available in the files are filtered and only the definitions of the ones requested are parsed.
type TypeResolver ¶
type TypeResolver interface { protoregistry.MessageTypeResolver protoregistry.ExtensionTypeResolver }
TypeResolver contains the methods needed to resolve proto types for implementing gRPC reflection or performing operations such as marshaling/unmarshaling protos to JSON. It is implemented by *protoregistry.Types and *dynamicpb.Types.