bufcurl

package
v0.0.0-...-da789b0 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2024 License: Apache-2.0 Imports: 36 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) (http.Header, 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 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 Container

type Container struct {
}

func (Container) AppName

func (c Container) AppName() string

func (Container) Arg

func (c Container) Arg(i int) string

func (Container) CacheDirPath

func (c Container) CacheDirPath() string

func (Container) ConfigDirPath

func (c Container) ConfigDirPath() string

func (Container) DataDirPath

func (c Container) DataDirPath() string

func (Container) Env

func (c Container) Env(key string) string

func (Container) ForEachEnv

func (c Container) ForEachEnv(f func(string, string))

func (Container) Logger

func (c Container) Logger() *zap.Logger

func (Container) NumArgs

func (c Container) NumArgs() int

func (Container) Port

func (c Container) Port() (uint16, error)

func (Container) Stderr

func (c Container) Stderr() io.Writer

func (Container) Stdin

func (c Container) Stdin() io.Reader

func (Container) Stdout

func (c Container) Stdout() io.Writer

func (Container) VerbosePrinter

func (c Container) VerbosePrinter() verbose.Printer

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, input rxgo.Observable, headers http.Header) error
}

Invoker provides the ability to invoke RPCs dynamically.

func NewInvoker

func NewInvoker(
	md protoreflect.MethodDescriptor,
	res protoencoding.Resolver,
	httpClient connect.HTTPClient,
	opts []connect.ClientOption,
	url string,
	out io.Writer,
	output rx.ItemSink,
) 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 ReflectionResolver

type ReflectionResolver struct {
	// contains filtered or unexported fields
}

func NewServerReflectionResolver

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

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

func (*ReflectionResolver) FindDescriptorByName

func (r *ReflectionResolver) FindDescriptorByName(name protoreflect.FullName) (protoreflect.Descriptor, error)

func (*ReflectionResolver) FindEnumByName

func (*ReflectionResolver) FindExtensionByName

func (r *ReflectionResolver) FindExtensionByName(field protoreflect.FullName) (protoreflect.ExtensionType, error)

func (*ReflectionResolver) FindExtensionByNumber

func (*ReflectionResolver) FindFileByPath

func (r *ReflectionResolver) FindFileByPath(path string) (protoreflect.FileDescriptor, error)

func (*ReflectionResolver) FindMessageByName

func (r *ReflectionResolver) FindMessageByName(message protoreflect.FullName) (protoreflect.MessageType, error)

func (*ReflectionResolver) FindMessageByURL

func (r *ReflectionResolver) FindMessageByURL(url string) (protoreflect.MessageType, error)

func (*ReflectionResolver) GetServices

func (*ReflectionResolver) Reset

func (r *ReflectionResolver) Reset()

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.

type ZeroLogPrinter

type ZeroLogPrinter struct{}

func (*ZeroLogPrinter) Printf

func (z *ZeroLogPrinter) Printf(format string, args ...interface{})

Directories

Path Synopsis
Package normalpath provides functions similar to filepath.
Package normalpath provides functions similar to filepath.
Package stringutil implements string utilities.
Package stringutil implements string utilities.

Jump to

Keyboard shortcuts

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