From 9982462b80bbfd6c47fdf0a05060626a1c9f2c8c Mon Sep 17 00:00:00 2001 From: Jehiah Czebotar Date: Fri, 20 Nov 2020 21:21:21 -0500 Subject: [PATCH] Set topology region+zone and send in IDENTIFY msg --- config.go | 4 ++++ conn.go | 2 ++ 2 files changed, 6 insertions(+) diff --git a/config.go b/config.go index 38fffe45..6fa9f510 100644 --- a/config.go +++ b/config.go @@ -140,6 +140,10 @@ type Config struct { Hostname string `opt:"hostname"` UserAgent string `opt:"user_agent"` + // Topology hints allow nsqd to prefer same zone and same region consumers + TopologyRegion string `opt:"topology_region"` + TopologyZone string `opt:"topology_zone"` + // Duration of time between heartbeats. This must be less than ReadTimeout HeartbeatInterval time.Duration `opt:"heartbeat_interval" default:"30s"` // Integer percentage to sample the channel (requires nsqd 0.2.25+) diff --git a/conn.go b/conn.go index 321da690..0f5ff3a2 100644 --- a/conn.go +++ b/conn.go @@ -345,6 +345,8 @@ func (c *Conn) identify() (*IdentifyResponse, error) { ci["output_buffer_timeout"] = int64(c.config.OutputBufferTimeout / time.Millisecond) } ci["msg_timeout"] = int64(c.config.MsgTimeout / time.Millisecond) + ci["topology_region"] = c.config.TopologyRegion + ci["topology_zone"] = c.config.TopologyZone cmd, err := Identify(ci) if err != nil { return nil, ErrIdentify{err.Error()}