https://github.com/advantageous/lokate-mesos
Uses Reakt Lokate Lib but add support for querying Mesos/Marathon location.
https://github.com/advantageous/lokate-mesos
Last synced: 10 months ago
JSON representation
Uses Reakt Lokate Lib but add support for querying Mesos/Marathon location.
- Host: GitHub
- URL: https://github.com/advantageous/lokate-mesos
- Owner: advantageous
- License: apache-2.0
- Created: 2016-08-19T19:14:52.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-08-23T18:20:30.000Z (over 9 years ago)
- Last Synced: 2025-01-22T11:47:57.612Z (12 months ago)
- Language: Java
- Size: 67.4 KB
- Stars: 0
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# lokate-mesos
Uses Reakt [Lokate Lib](https://github.com/advantageous/lokate) but adds support for querying [Mesos/Marathon](https://github.com/advantageous/lokate-mesos/wiki/Design-notes-on-using-the-Marathon-REST-API-to-do-discovery) location.
## Search by container port
```
# Default host
discovery:marathon:///eventbus.sample-dcos3?containerPort=8081
# Specify host
discovery:marathon://marathon.mesos:8080/eventbus.sample-dcos3?containerPort=8081
```
## Search by port name
```
# Default host
discovery:marathon:///eventbus.sample-dcos3?portName=eventbus
# Specify host
discovery:marathon://marathon.mesos:8080/eventbus.sample-dcos3?portName=eventbus
```
## Search by port index
```
# Default host
discovery:marathon:///eventbus.sample-dcos3?portIndex=0
# Specify host
discovery:marathon://marathon.mesos:8080/eventbus.sample-dcos3?portIndex=0
```
## Config URL
```java
URI.create("marathon://marathon.mesos:8080/")
```
See [Lokate](https://github.com/advantageous/lokate) for more sample usage.
## Example
####Gradle file
```
//Service discovery
compile 'io.advantageous.discovery:lokate-mesos:1.1.5'
```
#### Create discovery service that talks to mesos
```java
@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");
}
```
#### Use it
```java
...
@POST(value = "/service")
public final Promise> listServices(URI uri) {
logger.debug("List services");
return discoveryService.lookupService(uri);
}
```
#### Hit it from REST
```sh
$ 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](http://advantageous.github.io/reakt/) for its async promises.