From 091d258d1c1c222a410346af3efa28666c69351a Mon Sep 17 00:00:00 2001 From: Michal Kuratczyk Date: Wed, 8 Jan 2025 08:36:50 +0100 Subject: [PATCH] Add --tcp-nodelay option used in AMQP-1.0 Requires modified go-amqp --- cmd/root.go | 2 ++ go.mod | 2 ++ go.sum | 4 ++-- pkg/amqp10/consumer.go | 1 + pkg/amqp10/publisher.go | 1 + pkg/config/config.go | 1 + 6 files changed, 9 insertions(+), 2 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index eceecbd..fb11536 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -371,6 +371,8 @@ func RootCmd() *cobra.Command { "Binding key for queue declarations") rootCmd.PersistentFlags().StringVar(&cfg.Exchange, "exchange", "", "Exchange for binding declarations") + rootCmd.PersistentFlags().BoolVar(&cfg.TCPNoDelay, "tcp-nodelay", true, + "TCP_NODELAY (Nagle's algorithm)") // messages rootCmd.PersistentFlags().IntVarP(&cfg.Size, "size", "s", 12, "Message payload size in bytes") diff --git a/go.mod b/go.mod index 6f80fd8..4d1fcba 100644 --- a/go.mod +++ b/go.mod @@ -2,6 +2,8 @@ module github.com/rabbitmq/omq go 1.23.0 +replace github.com/Azure/go-amqp => github.com/mkuratczyk/go-amqp v0.0.0-20250107231955-7ba9aa503a31 + require ( github.com/Azure/go-amqp v1.4.0-beta.1 github.com/VictoriaMetrics/metrics v1.35.1 diff --git a/go.sum b/go.sum index 75696dc..672669d 100644 --- a/go.sum +++ b/go.sum @@ -1,6 +1,4 @@ cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -github.com/Azure/go-amqp v1.4.0-beta.1 h1:BjZM/308FpfsQjX0gXtYK8Vx+WgQ1eng3oVQDEeXMmA= -github.com/Azure/go-amqp v1.4.0-beta.1/go.mod h1:vZAogwdrkbyK3Mla8m/CxSc/aKdnTZ4IbPxl51Y5WZE= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/VictoriaMetrics/metrics v1.35.1 h1:o84wtBKQbzLdDy14XeskkCZih6anG+veZ1SwJHFGwrU= github.com/VictoriaMetrics/metrics v1.35.1/go.mod h1:r7hveu6xMdUACXvB8TYdAj8WEsKzWB0EkpJN+RDtOf8= @@ -158,6 +156,8 @@ github.com/michaelklishin/rabbit-hole v1.5.0 h1:Bex27BiFDsijCM9D0ezSHqyy0kehpYHu github.com/michaelklishin/rabbit-hole v1.5.0/go.mod h1:vvI1uOitYZi0O5HEGXhaWC1XT80Gy+HvFheJ+5Krlhk= github.com/miekg/dns v1.1.62 h1:cN8OuEF1/x5Rq6Np+h1epln8OiyPWV+lROx9LxcGgIQ= github.com/miekg/dns v1.1.62/go.mod h1:mvDlcItzm+br7MToIKqkglaGhlFMHJ9DTNNWONWXbNQ= +github.com/mkuratczyk/go-amqp v0.0.0-20250107231955-7ba9aa503a31 h1:UJnjCtPHTTbHCJ8Ccwif5ndt7jG3uU6vRbrchnOoMLE= +github.com/mkuratczyk/go-amqp v0.0.0-20250107231955-7ba9aa503a31/go.mod h1:vZAogwdrkbyK3Mla8m/CxSc/aKdnTZ4IbPxl51Y5WZE= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= diff --git a/pkg/amqp10/consumer.go b/pkg/amqp10/consumer.go index ac9a38f..140026a 100644 --- a/pkg/amqp10/consumer.go +++ b/pkg/amqp10/consumer.go @@ -75,6 +75,7 @@ func (c *Amqp10Consumer) Connect() { TLSConfig: &tls.Config{ ServerName: hostname, }, + TCPNoDelay: &c.Config.TCPNoDelay, }) if err != nil { select { diff --git a/pkg/amqp10/publisher.go b/pkg/amqp10/publisher.go index 65fd425..8fa913a 100644 --- a/pkg/amqp10/publisher.go +++ b/pkg/amqp10/publisher.go @@ -83,6 +83,7 @@ func (p *Amqp10Publisher) Connect() { TLSConfig: &tls.Config{ ServerName: hostname, }, + TCPNoDelay: &p.Config.TCPNoDelay, }) if err != nil { diff --git a/pkg/config/config.go b/pkg/config/config.go index 718bea4..8e50978 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -108,6 +108,7 @@ type Config struct { LogOutOfOrder bool PrintAllMetrics bool ConsumerStartupDelay time.Duration + TCPNoDelay bool } func NewConfig() Config {