bufcurl

package
v0.0.0-...-26f4575 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2023 License: Apache-2.0 Imports: 37 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// AllKnownReflectProtocolStrings are all string values for
	// ReflectProtocol that represent known reflection protocols.
	AllKnownReflectProtocolStrings = []string{
		"grpc-v1",
		"grpc-v1alpha",
	}
)

Functions

func DefaultUserAgent

func DefaultUserAgent(protocol string, bufVersion string) string

DefaultUserAgent returns the default user agent for the given protocol.

func DescriptorKind

func DescriptorKind(d protoreflect.Descriptor) string

DescriptorKind returns a succinct description of the type of the given descriptor.

func ErrorHasFilename

func ErrorHasFilename(err error, filename string) error

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

func GetAuthority(url *url.URL, headers http.Header) string

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 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 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 Resolver, 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
	// ReflectProtocolGRPCV1 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 Resolver

Resolver is an interface for resolving symbols into descriptors and for looking up extensions.

Note that resolver implementations must be thread-safe because they could be used by two goroutines concurrently during bidirectional streaming calls.

func NewImageResolver

func NewImageResolver(image bufimage.Image) (Resolver, error)

NewImageResolver returns a Resolver that uses the given image to resolve symbols and extensions.

func NewServerReflectionResolver

func NewServerReflectionResolver(
	ctx context.Context,
	httpClient connect.HTTPClient,
	opts []connect.ClientOption,
	baseURL string,
	reflectProtocol ReflectProtocol,
	headers http.Header,
	printer verbose.Printer,
) (r Resolver, closeResolver func())

NewServerReflectionResolver creates a new resolver using the given details to create an RPC reflection client, to ask the server for descriptors.

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
}

TLSSettings contains settings related to creating a TLS client.

Jump to

Keyboard shortcuts

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