internal

package
v1.0.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2023 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultHost is the default host to use for the server.
	DefaultHost = "127.0.0.1"
	// DefaultPort is the default port to use for the server. We choose 0 so that
	// an ephemeral port is selected by the OS if no port is specified.
	DefaultPort = 0
	// The fully-qualified service name for the Conformance Service.
	ConformanceServiceName = conformancev1connect.ConformanceServiceName
	// The prefix for type URLs used in Any messages.
	DefaultAnyResolverPrefix = "type.googleapis.com/"
)
View Source
const (
	ClientCertName = "Conformance Client"
	ServerCertName = "Conformance Server"
)

Variables

View Source
var (

	// Version is the version to report from all binaries.
	Version = buildVersion + buildVersionSuffix
)

Functions

func AddHeaders

func AddHeaders(
	src []*v1.Header,
	dest http.Header,
)

AddHeaders adds all header values in src to dest.

func AddTrailers

func AddTrailers(
	src []*v1.Header,
	dest http.Header,
)

AddTrailers adds all header values in src to dest, but it prefixes each header name with http.TrailerPrefix.

func ConvertConnectToProtoError

func ConvertConnectToProtoError(err *connect.Error) *v1.Error

ConvertConnectToProtoError converts the given Connect error to a proto Error message. If err is nil, the function will also return nil.

func ConvertErrorToConnectError

func ConvertErrorToConnectError(err error) *connect.Error

ConvertErrorToConnectError converts the given error to a Connect error If err is nil, function will also return nil. If err is not of type connect.Error, a Connect error of code Unknown is returned.

func ConvertErrorToProtoError

func ConvertErrorToProtoError(err error) *v1.Error

ConvertErrorToProtoError converts the given error to a proto Error If err is nil, function will also return nil. If err is not of type connect.Error, a code representing Unknown is returned.

func ConvertProtoToConnectError

func ConvertProtoToConnectError(err *v1.Error) *connect.Error

ConvertProtoToConnectError creates a Connect error from the given proto Error message.

func ConvertToProtoHeader

func ConvertToProtoHeader(src map[string][]string) []*v1.Header

ConvertToProtoHeader converts a map to a slice of proto Headers. Note that this can accept types of url.Values and http.Header.

func NewClientCert

func NewClientCert() (certBytes []byte, keyBytes []byte, err error)

NewClientCert is like NewServerCert, but it produces a certificate that is intended for client authentication. It also returns the encoded bytes of the private key.

func NewClientTLSConfig

func NewClientTLSConfig(caCert, clientCert, clientKey []byte) (*tls.Config, error)

NewClientTLSConfig returns a TLS configuration for an RPC client that uses the given PEM-encoded certs/keys. The caCert parameter must not be empty, and is the server certificate to trust (or a CA cert for the issuer of the server cert). The clientCert and clientKey parameters are optional. If one is provided then both must be present. They enable the use of a client certificate during the TLS handshake, for mutually-authenticated TLS.

func NewCodec

func NewCodec(json bool) codec

NewCodec returns a new Codec.

func NewServerCert

func NewServerCert() (tls.Certificate, []byte, error)

NewServerCert generates a new self-signed certificate. The first return value is usable with a *tls.Config. The second value is the PEM-encoded certificate which must be shared with clients for them to trust the server. Both will be zero values if the returned error is not nil.

func NewServerTLSConfig

func NewServerTLSConfig(cert tls.Certificate, clientCertMode tls.ClientAuthType, clientCACert []byte) (*tls.Config, error)

NewServerTLSConfig returns a TLS configuration for an RPC server that uses the given PEM-encoded cert/key. If the cert and key parameters are required. The clientCACert parameter is required unless clientCerts is tls.NoClientCert.

func ParseServerCert

func ParseServerCert(cert, key []byte) (tls.Certificate, error)

ParseServerCert parses the given PEM-encoded cert and key.

func ReadDelimitedMessage

func ReadDelimitedMessage[T proto.Message](in io.Reader, msg T) error

ReadDelimitedMessage reads the next message from in. This first reads a fixed four byte preface, which is a network-encoded (i.e. big-endian) 32-bit integer that represents the message size. This then reads a number of bytes equal to that size and unmarshals it into msg.

func WriteDelimitedMessage

func WriteDelimitedMessage[T proto.Message](out io.Writer, msg T) error

WriteDelimitedMessage writes msg to out in a way that can be read by ReadDelimitedMessage.

func WriteRawMessageContents

func WriteRawMessageContents(contents *conformancev1.MessageContents, writer io.Writer) error

WriteRawMessageContents writes the given message contents to the given writer.

func WriteRawStreamContents

func WriteRawStreamContents(contents *conformancev1.StreamContents, writer io.Writer) error

WriteRawStreamContents writes the given stream contents to the given writer.

Types

type CancelTiming

type CancelTiming struct {
	BeforeCloseSend   *emptypb.Empty
	AfterCloseSendMs  int
	AfterNumResponses int
}

func GetCancelTiming

func GetCancelTiming(cancel *v1.ClientCompatRequest_Cancel) (*CancelTiming, error)

GetCancelTiming evaluates a Cancel setting and returns a struct with the appropriate value set.

type Printer

type Printer interface {
	// Printf formats the given message and arguments. A newline
	// is automatically added, so it is not necessary to include
	// an explicit "\n" at the end.
	Printf(msg string, args ...any)
	// PrefixPrintf is just like Printf except it will print
	// the given prefix followed by ": " before printing the
	// messages and arguments.
	PrefixPrintf(prefix, msg string, args ...any)
}

Printer is a simple interface for formatting human-readable messages.

func NewPrinter

func NewPrinter(w io.Writer) Printer

NewPrinter returns a thread-safe printer that prints messages to the given writer. The returned printer may safely be used from concurrent goroutines, even if the given writer is not safe for concurrent use.

type StreamDecoder

type StreamDecoder interface {
	DecodeNext(msg proto.Message) error
}

StreamDecoder is used to decode messages from a stream. This is used when the input contains a sequence of messages, not just one.

type StreamEncoder

type StreamEncoder interface {
	Encode(msg proto.Message) error
}

StreamEncoder is used to encode messages to a stream. This is used when the output will contain a sequence of messages, not just one.

type TextConnectCodec

type TextConnectCodec struct {
	prototext.MarshalOptions
	prototext.UnmarshalOptions
}

TextConnectCodec implements the connect.Codec interface, providing the protobuf text format.

func (*TextConnectCodec) Marshal

func (t *TextConnectCodec) Marshal(a any) ([]byte, error)

func (*TextConnectCodec) Name

func (t *TextConnectCodec) Name() string

func (*TextConnectCodec) Unmarshal

func (t *TextConnectCodec) Unmarshal(bytes []byte, a any) error

Directories

Path Synopsis
app
connectconformance/testsuites
Package testsuites contains embedded test suite data used when running conformance tests.
Package testsuites contains embedded test suite data used when running conformance tests.
gen

Jump to

Keyboard shortcuts

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