Skip to content

Commit

Permalink
Update enum names
Browse files Browse the repository at this point in the history
  • Loading branch information
TylerHelmuth committed Jan 29, 2024
1 parent 5280d66 commit 68f1f55
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 35 deletions.
2 changes: 1 addition & 1 deletion config/configgrpc/configgrpc.go
Expand Up @@ -290,7 +290,7 @@ func (gss *GRPCServerSettings) ToServer(host component.Host, settings component.

func (gss *GRPCServerSettings) toServerOption(host component.Host, settings component.TelemetrySettings) ([]grpc.ServerOption, error) {
switch gss.NetAddr.Transport {
case confignet.TCP, confignet.TCP4, confignet.TCP6, confignet.UDP, confignet.UDP4, confignet.UDP6:
case confignet.TransportTypeTCP, confignet.TransportTypeTCP4, confignet.TransportTypeTCP6, confignet.TransportTypeUDP, confignet.TransportTypeUDP4, confignet.TransportTypeUDP6:
internal.WarnOnUnspecifiedHost(settings.Logger, gss.NetAddr.Endpoint)
}

Expand Down
6 changes: 3 additions & 3 deletions config/configgrpc/configgrpc_test.go
Expand Up @@ -701,7 +701,7 @@ func TestContextWithClient(t *testing.T) {
expected: client.Info{},
},
{
desc: "existing client with IP, no peer information",
desc: "existing client with TransportTypeIP, no peer information",
input: client.NewContext(context.Background(), client.Info{
Addr: &net.IPAddr{
IP: net.IPv4(1, 2, 3, 4),
Expand All @@ -727,7 +727,7 @@ func TestContextWithClient(t *testing.T) {
},
},
{
desc: "existing client, existing IP gets overridden with peer information",
desc: "existing client, existing TransportTypeIP gets overridden with peer information",
input: peer.NewContext(client.NewContext(context.Background(), client.Info{
Addr: &net.IPAddr{
IP: net.IPv4(1, 2, 3, 4),
Expand Down Expand Up @@ -1074,7 +1074,7 @@ func (gts *grpcTraceServer) Export(ctx context.Context, _ ptraceotlp.ExportReque
return ptraceotlp.NewExportResponse(), nil
}

// tempSocketName provides a temporary Unix socket name for testing.
// tempSocketName provides a temporary TransportTypeUnix socket name for testing.
func tempSocketName(t *testing.T) string {
tmpfile, err := os.CreateTemp("", "sock")
require.NoError(t, err)
Expand Down
60 changes: 30 additions & 30 deletions config/confignet/confignet.go
Expand Up @@ -14,37 +14,37 @@ import (
type TransportType string

const (
TCP TransportType = "tcp"
TCP4 TransportType = "tcp4"
TCP6 TransportType = "tcp6"
UDP TransportType = "udp"
UDP4 TransportType = "udp4"
UDP6 TransportType = "udp6"
IP TransportType = "ip"
IP4 TransportType = "ip4"
IP6 TransportType = "ip6"
Unix TransportType = "unix"
Unixgram TransportType = "unixgram"
UnixPacket TransportType = "unixpacket"
TransportTypeTCP TransportType = "tcp"
TransportTypeTCP4 TransportType = "tcp4"
TransportTypeTCP6 TransportType = "tcp6"
TransportTypeUDP TransportType = "udp"
TransportTypeUDP4 TransportType = "udp4"
TransportTypeUDP6 TransportType = "udp6"
TransportTypeIP TransportType = "ip"
TransportTypeIP4 TransportType = "ip4"
TransportTypeIP6 TransportType = "ip6"
TransportTypeUnix TransportType = "unix"
TransportTypeUnixgram TransportType = "unixgram"
TransportTypeUnixPacket TransportType = "unixpacket"
)

// UnmarshalText unmarshalls text to a TransportType.
// Valid values are "tcp", "tcp4", "tcp6", "udp", "udp4",
// "udp6", "ip", "ip4", "ip6", "unix", "unixgram" and "unixpacket"
func (tt *TransportType) UnmarshalText(in []byte) error {
switch typ := TransportType(in); typ {

Check warning on line 35 in config/confignet/confignet.go

View check run for this annotation

Codecov / codecov/patch

config/confignet/confignet.go#L34-L35

Added lines #L34 - L35 were not covered by tests
case TCP,
TCP4,
TCP6,
UDP,
UDP4,
UDP6,
IP,
IP4,
IP6,
Unix,
Unixgram,
UnixPacket:
case TransportTypeTCP,
TransportTypeTCP4,
TransportTypeTCP6,
TransportTypeUDP,
TransportTypeUDP4,
TransportTypeUDP6,
TransportTypeIP,
TransportTypeIP4,
TransportTypeIP6,
TransportTypeUnix,
TransportTypeUnixgram,
TransportTypeUnixPacket:
*tt = typ
return nil
default:
Expand All @@ -62,8 +62,8 @@ type DialerConfig struct {
// NetAddr represents a network endpoint address.
type NetAddr struct {
// Endpoint configures the address for this network connection.
// For TCP and UDP networks, the address has the form "host:port". The host must be a literal IP address,
// or a host name that can be resolved to IP addresses. The port must be a literal port number or a service name.
// For TransportTypeTCP and TransportTypeUDP networks, the address has the form "host:port". The host must be a literal TransportTypeIP address,
// or a host name that can be resolved to TransportTypeIP addresses. The port must be a literal port number or a service name.
// If the host is a literal IPv6 address it must be enclosed in square brackets, as in "[2001:db8::1]:80" or
// "[fe80::1%zone]:80". The zone specifies the scope of the literal IPv6 address as defined in RFC 4007.
Endpoint string `mapstructure:"endpoint"`
Expand Down Expand Up @@ -91,8 +91,8 @@ func (na *NetAddr) Listen(ctx context.Context) (net.Listener, error) {
// TCPAddr represents a TCP endpoint address.
type TCPAddr struct {
// Endpoint configures the address for this network connection.
// The address has the form "host:port". The host must be a literal IP address, or a host name that can be
// resolved to IP addresses. The port must be a literal port number or a service name.
// The address has the form "host:port". The host must be a literal TransportTypeIP address, or a host name that can be
// resolved to TransportTypeIP addresses. The port must be a literal port number or a service name.
// If the host is a literal IPv6 address it must be enclosed in square brackets, as in "[2001:db8::1]:80" or
// "[fe80::1%zone]:80". The zone specifies the scope of the literal IPv6 address as defined in RFC 4007.
Endpoint string `mapstructure:"endpoint"`
Expand All @@ -104,11 +104,11 @@ type TCPAddr struct {
// Dial equivalent with net.Dialer's DialContext for this address.
func (na *TCPAddr) Dial(ctx context.Context) (net.Conn, error) {
d := net.Dialer{Timeout: na.DialerConfig.Timeout}
return d.DialContext(ctx, string(TCP), na.Endpoint)
return d.DialContext(ctx, string(TransportTypeTCP), na.Endpoint)
}

// Listen equivalent with net.ListenConfig's Listen for this address.
func (na *TCPAddr) Listen(ctx context.Context) (net.Listener, error) {
lc := net.ListenConfig{}
return lc.Listen(ctx, string(TCP), na.Endpoint)
return lc.Listen(ctx, string(TransportTypeTCP), na.Endpoint)
}
2 changes: 1 addition & 1 deletion receiver/otlpreceiver/factory.go
Expand Up @@ -46,7 +46,7 @@ func createDefaultConfig() component.Config {
GRPC: &configgrpc.GRPCServerSettings{
NetAddr: confignet.NetAddr{
Endpoint: localhostgate.EndpointForPort(grpcPort),
Transport: confignet.TCP,
Transport: confignet.TransportTypeTCP,
},
// We almost write 0 bytes, so no need to tune WriteBufferSize.
ReadBufferSize: 512 * 1024,
Expand Down

0 comments on commit 68f1f55

Please sign in to comment.