Uses Reakt Lokate Lib but adds support for querying Mesos/Marathon location.
# Default host
discovery:marathon:///eventbus.sample-dcos3?containerPort=8081
# Specify host
discovery:marathon://marathon.mesos:8080/eventbus.sample-dcos3?containerPort=8081
# Default host
discovery:marathon:///eventbus.sample-dcos3?portName=eventbus
# Specify host
discovery:marathon://marathon.mesos:8080/eventbus.sample-dcos3?portName=eventbus
# Default host
discovery:marathon:///eventbus.sample-dcos3?portIndex=0
# Specify host
discovery:marathon://marathon.mesos:8080/eventbus.sample-dcos3?portIndex=0
URI.create("marathon://marathon.mesos:8080/")
See Lokate for more sample usage.
####Gradle file
//Service discovery
compile 'io.advantageous.discovery:lokate-mesos:1.1.5'
@RequestMapping("/todo-service")
public class TodoServiceImpl implements TodoService {
...
private final DiscoveryService discoveryService;
public TodoServiceImpl(ServiceManagementBundle mgmt, TodoRepo todoRepo) {
...
logger.info("Creating discovery service");
discoveryService = DiscoveryService.create(URI.create("marathon://marathon.mesos:8080/"));
logger.info("Todo service created");
}
...
@POST(value = "/service")
public final Promise<List<URI>> listServices(URI uri) {
logger.debug("List services");
return discoveryService.lookupService(uri);
}
$ curl -X POST http://public-slave:10101/v1/todo-service/service -d '"discovery:marathon:///sample-dcos3?portIndex=0"' -H "Content-type: application/json" | jq .
[
"service://10.16.204.94:2838",
"service://10.16.204.95:26078",
"service://10.16.204.95:23568"
]
Lokate uses Reakt for its async promises.