Documentation ¶
Index ¶
- Variables
- func DefaultUserAgent(protocol string, bufVersion string) string
- func ErrorHasFilename(err error, filename string) error
- func GetAuthority(url *url.URL, headers http.Header) string
- func LoadHeaders(headerFlags []string, dataFile string, others http.Header) (http.Header, io.ReadCloser, error)
- func MakeVerboseTLSConfig(settings *TLSSettings, authority string, printer verbose.Printer) (*tls.Config, error)
- func NewServerReflectionResolver(ctx context.Context, httpClient connect.HTTPClient, ...) (r protoencoding.Resolver, closeResolver func())
- func NewVerboseHTTPClient(transport http.RoundTripper, printer verbose.Printer) connect.HTTPClient
- func ResolveMethodDescriptor(res protoencoding.Resolver, service, method string) (protoreflect.MethodDescriptor, error)
- func TraceTrailersInterceptor(printer verbose.Printer) connect.Interceptor
- type Invoker
- type ReflectProtocol
- type TLSSettings
Constants ¶
This section is empty.
Variables ¶
var ( // AllKnownReflectProtocolStrings are all string values for // ReflectProtocol that represent known reflection protocols. AllKnownReflectProtocolStrings = []string{ "grpc-v1", "grpc-v1alpha", } )
Functions ¶
func DefaultUserAgent ¶
DefaultUserAgent returns the default user agent for the given protocol.
func ErrorHasFilename ¶
ErrorHasFilename makes sure that the given error includes a reference to the given filename. If not, it wraps the given error and adds the filename. This is to make sure errors are useful -- an error related to file I/O is not very helpful if it doesn't indicate the name of the file.
func GetAuthority ¶
GetAuthority determines the authority for a request with the given URL and request headers. If headers include a "Host" header, that is used. (If the request contains more than one, that is usually not valid or acceptable to servers, but this function will look at only the first.) If there is no such header, the authority is the host portion of the URL (both the domain name/IP address and port).
func LoadHeaders ¶
func LoadHeaders(headerFlags []string, dataFile string, others http.Header) (http.Header, io.ReadCloser, error)
LoadHeaders computes the set of request headers from the given flag values, loading from file(s) if so instructed. A header flag is usually in the form "name: value", but it may start with "@" to indicate a filename from which headers are loaded. It may also be "*", to indicate that the given others are included in full.
If the filename following an "@" header flag is "-", it means to read from stdin.
The given dataFile is the name of a file from which request data is read. If a "@" header flag indicates to read from the same file, then the headers must be at the start of the file, following by a blank line, followed by the actual request body. In such a case, the returned ReadCloser will be non-nil and correspond to that point in the file (after headers and blank line), so the request body can be read from it.
func MakeVerboseTLSConfig ¶
func MakeVerboseTLSConfig(settings *TLSSettings, authority string, printer verbose.Printer) (*tls.Config, error)
MakeVerboseTLSConfig constructs a *tls.Config that logs information to the given printer as a TLS connection is negotiated.
func NewServerReflectionResolver ¶
func NewServerReflectionResolver( ctx context.Context, httpClient connect.HTTPClient, opts []connect.ClientOption, baseURL string, reflectProtocol ReflectProtocol, headers http.Header, printer verbose.Printer, ) (r protoencoding.Resolver, closeResolver func())
NewServerReflectionResolver creates a new resolver using the given details to create an RPC reflection client, to ask the server for descriptors.
func NewVerboseHTTPClient ¶
func NewVerboseHTTPClient(transport http.RoundTripper, printer verbose.Printer) connect.HTTPClient
NewVerboseHTTPClient creates a new HTTP client with the given transport and printing verbose trace information to the given printer.
func ResolveMethodDescriptor ¶
func ResolveMethodDescriptor(res protoencoding.Resolver, service, method string) (protoreflect.MethodDescriptor, error)
ResolveMethodDescriptor uses the given resolver to find a descriptor for the requested service and method. The service name must be fully-qualified.
func TraceTrailersInterceptor ¶
func TraceTrailersInterceptor(printer verbose.Printer) connect.Interceptor
TraceTrailersInterceptor returns an interceptor that will print information about trailers for streaming calls to the given printer. This is used with the Connect and gRPC-web protocols since these protocols include trailers in the request body, instead of using actual HTTP trailers. (For the gRPC protocol, which uses actual HTTP trailers, the verbose HTTP client suffices since it already prints information about the trailers.)
Types ¶
type Invoker ¶
type Invoker interface { // Invoke invokes an RPC method using the given input data and request headers. // The dataSource is a string that describes the input data (e.g. a filename). // The actual contents of the request data is read from the given reader. Invoke(ctx context.Context, dataSource string, data io.Reader, headers http.Header) error }
Invoker provides the ability to invoke RPCs dynamically.
func NewInvoker ¶
func NewInvoker(container appflag.Container, md protoreflect.MethodDescriptor, res protoencoding.Resolver, emitDefaults bool, httpClient connect.HTTPClient, opts []connect.ClientOption, url string, out io.Writer) Invoker
NewInvoker creates a new invoker for invoking the method described by the given descriptor. The given writer is used to write the output response(s) in JSON format. The given resolver is used to resolve Any messages and extensions that appear in the input or output. Other parameters are used to create a Connect client, for issuing the RPC.
type ReflectProtocol ¶
type ReflectProtocol int
ReflectProtocol is a reflection protocol.
const ( // ReflectProtocolUnknown represents that the server reflection protocol // is unknown. If given this value, the server reflection resolver will // cycle through the known reflection protocols from newest to oldest, // trying each one until a reflection protocol that works is found. ReflectProtocolUnknown ReflectProtocol = iota + 1 // ReflectProtocolGRPCV1 represents the gRPC server reflection protocol // defined by the service grpc.reflection.v1.ServerReflection. ReflectProtocolGRPCV1 // ReflectProtocolGRPCV1Alpha represents the gRPC server reflection protocol // defined by the service grpc.reflection.v1alpha.ServerReflection. ReflectProtocolGRPCV1Alpha )
func ParseReflectProtocol ¶
func ParseReflectProtocol(s string) (ReflectProtocol, error)
ParseReflectProtocol parses the ReflectProtocol.
The empty string is a parse error.
func (ReflectProtocol) String ¶
func (r ReflectProtocol) String() string
String implements fmt.Stringer.
type TLSSettings ¶
type TLSSettings struct {
// Filenames for a private key, certificate, and CA certificate pool.
KeyFile, CertFile, CACertFile string
// Override server name, for SNI.
ServerName string
// If true, the server's certificate is not verified.
Insecure bool
// If true, the server is known to support HTTP/2. When set, the
// ALPN protocols sent during the TLS handshake will include only
// "h2", and exclude "http/1.1". If the server does not pick a
// protocol, "h2" is assumed as the default.
HTTP2PriorKnowledge bool
}
TLSSettings contains settings related to creating a TLS client.