forked from jhalterman/lyra
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changes to use an address resolver which resolves the next address to…
… attempt for a connection. This is towards issue jhalterman#17 (jhalterman#17)
- Loading branch information
Srinath C
committed
Nov 22, 2013
1 parent
3de6e43
commit 755be9e
Showing
3 changed files
with
92 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package net.jodah.lyra; | ||
|
||
import com.rabbitmq.client.Address; | ||
|
||
/** | ||
* Address resolver to resolve the addresses | ||
* | ||
* @author Srinath C | ||
*/ | ||
public interface AddressResolver { | ||
|
||
Address nextAddress(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package net.jodah.lyra; | ||
|
||
import com.rabbitmq.client.Address; | ||
|
||
/** | ||
* Address resolver to resolve the addresses | ||
* | ||
* @author Srinath C | ||
*/ | ||
public class DefaultAddressResolver implements AddressResolver { | ||
|
||
private final Address[] addresses; | ||
|
||
private int nextIndex = 0; | ||
|
||
public DefaultAddressResolver(Address[] addresses) { | ||
this.addresses = addresses; | ||
} | ||
|
||
@Override | ||
public Address nextAddress() { | ||
if (addresses == null || addresses.length > 0) { | ||
return null; | ||
} | ||
if (nextIndex >= addresses.length ) { | ||
nextIndex = 0; | ||
} | ||
return addresses[nextIndex++]; | ||
} | ||
} |