Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
replace client every time ECONNREFUSED occurs
  • Loading branch information
Francisco Treacy committed Feb 7, 2011
1 parent f6c27cd commit 8fbc95f
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/http_client.coffee
Expand Up @@ -9,13 +9,16 @@ class HttpClient extends Client
# client-specific defaults
[host, port] = ['localhost', 8098]
super options
@client = Http.createClient options?.port or port, options?.host or host

init = =>
@client = Http.createClient options?.port or port, options?.host or host

@client.on 'error', (err) =>
@emit 'clientError', err
if err.errno is process.ECONNREFUSED
@client.on 'error', (err) =>
@emit 'clientError', err
# if connection is refused (node down) leave a client ready for when it's up again
@client = Http.createClient(@client.port, @client.host)
if err.errno is process.ECONNREFUSED then init()

init()


get: (bucket, key, options...) ->
Expand Down

0 comments on commit 8fbc95f

Please sign in to comment.