-
Notifications
You must be signed in to change notification settings - Fork 7
/
HelloConsul.java
34 lines (29 loc) · 1.09 KB
/
HelloConsul.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package com.github.secondbase.example.main;
import com.github.secondbase.consul.ConsulModule;
import com.github.secondbase.consul.ConsulModuleConfiguration;
import com.github.secondbase.core.SecondBaseException;
/**
* Example of how to use the {@link ConsulModule} to register a service.
*/
public final class HelloConsul {
private HelloConsul() {}
public static void main(final String[] args) throws SecondBaseException {
final String serviceName = "myservice";
final int servicePort = 8080;
final String environment = "testing";
final String healthCheckPath = "/health";
final long healthCheckIntervalSec = 29L;
final String[] tags = {"tagone", "tagtwo"};
// Set consul endpoint
ConsulModuleConfiguration.host = "localhost:8500";
// Manually register a service in consul
new ConsulModule().registerServiceInConsul(
serviceName,
servicePort,
environment,
healthCheckPath,
healthCheckIntervalSec,
tags
);
}
}