-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Provide Service Registration feature in a standalone way
- Loading branch information
1 parent
acd61c7
commit 73820d6
Showing
62 changed files
with
1,459 additions
and
749 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
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
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
2 changes: 1 addition & 1 deletion
2
...cediscovery/consul/ConsulMetadataKey.java → ...mallrye/stork/impl/ConsulMetadataKey.java
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
2 changes: 1 addition & 1 deletion
2
...cediscovery/eureka/EurekaMetadataKey.java → ...mallrye/stork/impl/EurekaMetadataKey.java
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
40 changes: 40 additions & 0 deletions
40
core/src/main/java/io/smallrye/stork/utils/InMemoryAddressesBackend.java
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,40 @@ | ||
package io.smallrye.stork.utils; | ||
|
||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
public class InMemoryAddressesBackend { | ||
|
||
private static Map<String, List<String>> backend = new HashMap<>(); | ||
|
||
public static List<String> getAddresses(String serviceName) { | ||
return backend.get(serviceName); | ||
} | ||
|
||
public static void add(String serviceName, String address) { | ||
if (serviceName == null || serviceName.length() == 0) { | ||
throw new IllegalArgumentException("No service name provided for address " + address); | ||
} | ||
if (backend.get(serviceName) != null) { | ||
if (!backend.get(serviceName).contains(address)) { | ||
backend.get(serviceName).add(address); | ||
} | ||
} else { | ||
List<String> addresses = new ArrayList<>(); | ||
addresses.add(address); | ||
backend.put(serviceName, addresses); | ||
} | ||
} | ||
|
||
public static void clear(String serviceName) { | ||
if (backend != null) { | ||
backend.remove(serviceName); | ||
} | ||
} | ||
|
||
public static void clearAll() { | ||
backend.clear(); | ||
} | ||
} |
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,36 @@ | ||
package io.smallrye.stork; | ||
|
||
import io.smallrye.stork.api.MetadataKey; | ||
|
||
public enum TestMetadataKey implements MetadataKey { | ||
|
||
/** | ||
* The key for the consul service id. | ||
*/ | ||
META_CONSUL_SERVICE_ID("consul-service-id"), | ||
/** | ||
* The key for the consul service node. | ||
*/ | ||
META_CONSUL_SERVICE_NODE("consul-service-node"), | ||
/** | ||
* The key for the consul service node address. | ||
*/ | ||
META_CONSUL_SERVICE_NODE_ADDRESS("consul-service-node-address"); | ||
|
||
private final String name; | ||
|
||
/** | ||
* Creates a new ConsulMetadataKey | ||
* | ||
* @param name the name | ||
*/ | ||
TestMetadataKey(String name) { | ||
this.name = name; | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return name; | ||
} | ||
|
||
} |
Oops, something went wrong.