Documentation ¶
Index ¶
- Constants
- Variables
- func AddHeaders(src []*conformancev1.Header, dest http.Header)
- func AddTrailers(src []*conformancev1.Header, dest http.Header)
- func ConvertConnectToProtoError(err *connect.Error) *conformancev1.Error
- func ConvertErrorToConnectError(err error) *connect.Error
- func ConvertErrorToProtoError(err error) *conformancev1.Error
- func ConvertProtoToConnectError(err *conformancev1.Error) *connect.Error
- func ConvertToProtoHeader(src map[string][]string) []*conformancev1.Header
- func EnsureFileName(err error, filename string) error
- func NewClientCert() (certBytes, keyBytes []byte, err error)
- func NewClientTLSConfig(caCert, clientCert, clientKey []byte) (*tls.Config, error)
- func NewServerCert() (certBytes, keyBytes []byte, err error)
- func NewServerTLSConfig(cert tls.Certificate, clientCertMode tls.ClientAuthType, clientCACert []byte) (*tls.Config, error)
- func ParseServerCert(cert, key []byte) (tls.Certificate, error)
- func ReadDelimitedMessage[T proto.Message](in io.Reader, msg T, source string, timeout time.Duration, maxSize int) error
- func WriteDelimitedMessage[T proto.Message](out io.Writer, msg T) error
- func WriteRawMessageContents(contents *conformancev1.MessageContents, writer io.Writer) error
- func WriteRawStreamContents(contents *conformancev1.StreamContents, writer io.Writer) error
- type CancelTiming
- type Codec
- type Printer
- type SimplePrinter
- type StreamDecoder
- type StreamEncoder
- type StrictJSONCodec
- func (s StrictJSONCodec) IsBinary() bool
- func (s StrictJSONCodec) Marshal(msg any) ([]byte, error)
- func (s StrictJSONCodec) MarshalAppend(b []byte, msg any) ([]byte, error)
- func (s StrictJSONCodec) MarshalStable(msg any) ([]byte, error)
- func (s StrictJSONCodec) Name() string
- func (s StrictJSONCodec) Unmarshal(data []byte, msg any) error
- type StrictProtoCodec
- func (s StrictProtoCodec) IsBinary() bool
- func (s StrictProtoCodec) Marshal(msg any) ([]byte, error)
- func (s StrictProtoCodec) MarshalAppend(b []byte, msg any) ([]byte, error)
- func (s StrictProtoCodec) MarshalStable(msg any) ([]byte, error)
- func (s StrictProtoCodec) Name() string
- func (s StrictProtoCodec) Unmarshal(data []byte, msg any) error
Constants ¶
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/" )
const ( ClientCertName = "Conformance Client" ServerCertName = "Conformance Server" )
Variables ¶
var (
// Version is the version to report from all binaries.
Version = buildVersion + buildVersionSuffix
)
Functions ¶
func AddHeaders ¶
func AddHeaders( src []*conformancev1.Header, dest http.Header, )
AddHeaders adds all header values in src to dest.
func AddTrailers ¶
func AddTrailers( src []*conformancev1.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) *conformancev1.Error
ConvertConnectToProtoError converts the given Connect error to a proto Error message. If err is nil, the function will also return nil.
func ConvertErrorToConnectError ¶
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) *conformancev1.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 *conformancev1.Error) *connect.Error
ConvertProtoToConnectError creates a Connect error from the given proto Error message.
func ConvertToProtoHeader ¶
func ConvertToProtoHeader(src map[string][]string) []*conformancev1.Header
ConvertToProtoHeader converts a map to a slice of proto Headers. Note that this can accept types of url.Values and http.Header.
func EnsureFileName ¶
EnsureFileName ensures that the given error includes the given filename. If it does not, it wraps the error in one that does include the filename. This is used to ensure that file-system-specific errors have good messages and unambiguously indicate which file was the cause of the error.
func NewClientCert ¶
NewClientCert is like NewServerCert, but it produces a certificate that is intended for client authentication.
func NewClientTLSConfig ¶
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 NewServerCert ¶
NewServerCert generates a new self-signed certificate. The first return value is usable with a *tls.Config. The next two values are the PEM-encoded certificate (which must be shared with clients for them to trust the server) and key (which should not be shared). All three 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, source string, timeout time.Duration, maxSize int) 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 ¶
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 *conformancev1.ClientCompatRequest_Cancel) (*CancelTiming, error)
GetCancelTiming evaluates a Cancel setting and returns a struct with the appropriate value set.
type Codec ¶
type Codec interface { NewDecoder(io.Reader) StreamDecoder NewEncoder(io.Writer) StreamEncoder }
Codec describes anything that can marshal and unmarshal proto messages.
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 ¶
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 SimplePrinter ¶
type SimplePrinter struct {
Messages []string
}
SimplePrinter is a non-thread-safe printer that stores the printed messages in a slice.
func (*SimplePrinter) PrefixPrintf ¶
func (l *SimplePrinter) PrefixPrintf(prefix, msg string, args ...any)
func (*SimplePrinter) Printf ¶
func (l *SimplePrinter) Printf(msg string, args ...any)
type StreamDecoder ¶
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 ¶
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 StrictJSONCodec ¶ added in v1.0.3
type StrictJSONCodec struct{}
StrictJSONCodec is a codec for connect (and implements the optional methods for stable output and for appending to existing bytes for better performance). It is like Connect's builtin JSON codec, except that it does NOT allow unrecognized field names. (Connect's default JSON codec is lenient and discards unrecognized fields.)
func (StrictJSONCodec) IsBinary ¶ added in v1.0.3
func (s StrictJSONCodec) IsBinary() bool
func (StrictJSONCodec) Marshal ¶ added in v1.0.3
func (s StrictJSONCodec) Marshal(msg any) ([]byte, error)
func (StrictJSONCodec) MarshalAppend ¶ added in v1.0.3
func (s StrictJSONCodec) MarshalAppend(b []byte, msg any) ([]byte, error)
func (StrictJSONCodec) MarshalStable ¶ added in v1.0.3
func (s StrictJSONCodec) MarshalStable(msg any) ([]byte, error)
func (StrictJSONCodec) Name ¶ added in v1.0.3
func (s StrictJSONCodec) Name() string
type StrictProtoCodec ¶ added in v1.0.3
type StrictProtoCodec struct{}
StrictProtoCodec is a codec for connect (and implements the optional methods for stable output and for appending to existing bytes for better performance). It is like Connect's builtin Proto codec, except that it does NOT allow unrecognized fields. If the peer sends a message where not all elements are recognized, it will return an error.
func (StrictProtoCodec) IsBinary ¶ added in v1.0.3
func (s StrictProtoCodec) IsBinary() bool
func (StrictProtoCodec) Marshal ¶ added in v1.0.3
func (s StrictProtoCodec) Marshal(msg any) ([]byte, error)
func (StrictProtoCodec) MarshalAppend ¶ added in v1.0.3
func (s StrictProtoCodec) MarshalAppend(b []byte, msg any) ([]byte, error)
func (StrictProtoCodec) MarshalStable ¶ added in v1.0.3
func (s StrictProtoCodec) MarshalStable(msg any) ([]byte, error)
func (StrictProtoCodec) Name ¶ added in v1.0.3
func (s StrictProtoCodec) Name() string
Source Files ¶
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
|
|