use of com.orbitz.consul.Consul in project jim-framework by jiangmin168168.
the class ConsulRegistryService method register.
@Override
public void register(RpcURL url) {
Consul consul = this.buildConsul(url.getRegistryHost(), url.getRegistryPort());
AgentClient agent = consul.agentClient();
ImmutableRegCheck check = ImmutableRegCheck.builder().tcp(url.getHost() + ":" + url.getPort()).interval(CONSUL_HEALTH_INTERVAL).build();
ImmutableRegistration.Builder builder = ImmutableRegistration.builder();
builder.id(CONSUL_ID).name(CONSUL_NAME).addTags(CONSUL_TAGS).address(url.getHost()).port(url.getPort()).addChecks(check);
agent.register(builder.build());
}
use of com.orbitz.consul.Consul in project wildfly-swarm by wildfly-swarm.
the class AgentActivator method activate.
@Override
public void activate(ServiceActivatorContext context) throws ServiceRegistryException {
ServiceTarget target = context.getServiceTarget();
ConsulService consul = new ConsulService(this.fraction.url());
target.addService(ConsulService.SERVICE_NAME, consul).install();
HealthClientService healthClient = new HealthClientService();
target.addService(HealthClientService.SERIVCE_NAME, healthClient).addDependency(ConsulService.SERVICE_NAME, Consul.class, healthClient.getConsulInjector()).install();
CatalogClientService catalogClient = new CatalogClientService();
target.addService(CatalogClientService.SERVICE_NAME, catalogClient).addDependency(ConsulService.SERVICE_NAME, Consul.class, catalogClient.getConsulInjector()).install();
AgentClientService agentClient = new AgentClientService();
target.addService(AgentClientService.SERVICE_NAME, agentClient).addDependency(ConsulService.SERVICE_NAME, Consul.class, agentClient.getConsulInjector()).install();
Advertiser advertiser = new Advertiser();
target.addService(Advertiser.SERVICE_NAME, advertiser).addDependency(AgentClientService.SERVICE_NAME, AgentClient.class, advertiser.getAgentClientInjector()).install();
}
use of com.orbitz.consul.Consul in project ff4j by ff4j.
the class PropertyStoreConsulEmbeddedTest method initPropertyStore.
/**
* {@inheritDoc}
*/
protected PropertyStore initPropertyStore() {
Consul c = Consul.builder().withUrl("http://localhost:8800").build();
ConsulConnection connection = new ConsulConnection(c);
PropertyStoreConsul consulStore = new PropertyStoreConsul(connection);
consulStore.importPropertiesFromXmlFile("ff4j.xml");
return consulStore;
}
use of com.orbitz.consul.Consul in project ff4j by ff4j.
the class FeatureStoreConsulEmbeddedTest method initStore.
/**
* {@inheritDoc}
*/
protected FeatureStore initStore() {
Consul c = Consul.builder().withUrl("http://localhost:8800").build();
ConsulConnection connection = new ConsulConnection(c);
FeatureStoreConsul ehcacheStore = new FeatureStoreConsul(connection);
ehcacheStore.importFeaturesFromXmlFile("ff4j.xml");
return ehcacheStore;
}
use of com.orbitz.consul.Consul in project wildfly-swarm by wildfly-swarm.
the class ConsulService method start.
@Override
public void start(StartContext startContext) throws StartException {
Consul.Builder builder = Consul.builder();
// pool because of multiple threads.
ResteasyClientBuilder clientBuilder = new ResteasyClientBuilder();
clientBuilder = clientBuilder.connectionPoolSize(20);
builder.withClientBuilder(clientBuilder);
builder.withUrl(this.url);
try {
this.consul = builder.build();
} catch (Exception e) {
throw new StartException("Failed to connect consul at " + url, e);
}
}
Aggregations