Repository: grpc/grpc-go
File: rpc_util.go (Go)

Code before:
//
// # Experimental
//
// Notice: This type is EXPERIMENTAL and may be changed or removed in a
// later release.
type CompressorCallOption struct {
	CompressorType string
}

func (o CompressorCallOption) before(c *callInfo) error {
	c.compressorName = o.CompressorType
	return nil
}
func (o CompressorCallOption) after(*callInfo, *csAttempt) {}

// AcceptCompressors returns a CallOption that limits the compression algorithms
// advertised in the grpc-accept-encoding header for response messages.
// Compression algorithms not in the provided list will not be advertised, and
// responses compressed with non-listed algorithms will be rejected.
func AcceptCompressors(names ...string) CallOption {
	cp := append([]string(nil), names...)
	return AcceptCompressorsCallOption{names: cp}
}

// AcceptCompressorsCallOption is a CallOption that limits response compression.
type AcceptCompressorsCallOption struct {
	names []string
}

func (o AcceptCompressorsCallOption) before(c *callInfo) error {
	allowed, err := newAcceptedCompressionConfig(o.names)
	if err != nil {
		return err
	}
	c.acceptedResponseCompressors = allowed
	return nil
}

func (AcceptCompressorsCallOption) after(*callInfo, *csAttempt) {}

// CallContentSubtype returns a CallOption that will set the content-subtype
// for a call. For example, if content-subtype is "json", the Content-Type over
// the wire will be "application/grpc+json". The content-subtype is converted
// to lowercase before being included in Content-Type. See Content-Type on
// https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md#requests for
// more details.
//
// If ForceCodec is not also used, the content-subtype will be used to look up
// the Codec to use in the registry controlled by RegisterCodec. See the
// documentation on RegisterCodec for details on registration. The lookup of
// content-subtype is case-insensitive. If no such Codec is found, the call

Review comment (suggestion):
This should also be unexported but ideally exposed via `experimental` -- if that isn't easy to do, then ignore this and let's just leave it completely hidden for now.

Code after:
//
// # Experimental
//
// Notice: This type is EXPERIMENTAL and may be changed or removed in a
// later release.
type CompressorCallOption struct {
	CompressorType string
}

func (o CompressorCallOption) before(c *callInfo) error {
	c.compressorName = o.CompressorType
	return nil
}
func (o CompressorCallOption) after(*callInfo, *csAttempt) {}

// acceptCompressors returns a CallOption that limits the compression algorithms
// advertised in the grpc-accept-encoding header for response messages.
// Compression algorithms not in the provided list will not be advertised, and
// responses compressed with non-listed algorithms will be rejected.
func acceptCompressors(names ...string) CallOption {
	cp := append([]string(nil), names...)
	return acceptCompressorsCallOption{names: cp}
}

// acceptCompressorsCallOption is a CallOption that limits response compression.
type acceptCompressorsCallOption struct {
	names []string
}

func (o acceptCompressorsCallOption) before(c *callInfo) error {
	allowed, err := newAcceptedCompressionConfig(o.names)
	if err != nil {
		return err
	}
	c.acceptedResponseCompressors = allowed
	return nil
}

func (acceptCompressorsCallOption) after(*callInfo, *csAttempt) {}

// CallContentSubtype returns a CallOption that will set the content-subtype
// for a call. For example, if content-subtype is "json", the Content-Type over
// the wire will be "application/grpc+json". The content-subtype is converted
// to lowercase before being included in Content-Type. See Content-Type on
// https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md#requests for
// more details.
//
// If ForceCodec is not also used, the content-subtype will be used to look up
// the Codec to use in the registry controlled by RegisterCodec. See the
// documentation on RegisterCodec for details on registration. The lookup of
// content-subtype is case-insensitive. If no such Codec is found, the call