internal

package
v1.0.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2023 License: Apache-2.0 Imports: 22 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 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 http.Header,
) []*v1.Header

ConvertToProtoHeader converts HTTP headers to a slice of proto Headers.

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.

Types

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