Skip to content

Commit

Permalink
add custom hostname
Browse files Browse the repository at this point in the history
  • Loading branch information
andyxning committed Aug 4, 2017
1 parent 2d5e2aa commit 254dfd1
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions nsq/async.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ class AsyncConn(event.EventedMixin):
:param msg_timeout: the amount of time (in seconds) that nsqd will wait
before considering messages that have been delivered to this
consumer timed out (requires nsqd 0.2.28+)
:param hostname: a string identifying the host where this client runs
(default: ``<hostname>``)
"""
def __init__(
self,
Expand All @@ -147,7 +150,8 @@ def __init__(
sample_rate=0,
io_loop=None,
auth_secret=None,
msg_timeout=None):
msg_timeout=None,
hostname=None):
assert isinstance(host, string_types)
assert isinstance(port, int)
assert isinstance(timeout, float)
Expand Down Expand Up @@ -180,7 +184,9 @@ def __init__(
self.snappy = snappy
self.deflate = deflate
self.deflate_level = deflate_level
self.hostname = socket.gethostname()
self.hostname = hostname
if self.hostname is None:
self.hostname = socket.gethostname()
self.short_hostname = self.hostname.split('.')[0]
self.heartbeat_interval = heartbeat_interval * 1000
self.msg_timeout = int(msg_timeout * 1000) if msg_timeout else None
Expand Down

0 comments on commit 254dfd1

Please sign in to comment.