Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dinstone/clutch
Clutch is a service registry and discovery component, that provides an infrastructure to publish and discover various resources, such as service proxies, HTTP endpoints, data sources.
https://github.com/dinstone/clutch
service-discovery
Last synced: about 1 month ago
JSON representation
Clutch is a service registry and discovery component, that provides an infrastructure to publish and discover various resources, such as service proxies, HTTP endpoints, data sources.
- Host: GitHub
- URL: https://github.com/dinstone/clutch
- Owner: dinstone
- Created: 2017-09-28T09:02:47.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2022-09-09T08:45:10.000Z (over 2 years ago)
- Last Synced: 2023-07-26T21:37:42.817Z (over 1 year ago)
- Topics: service-discovery
- Language: Java
- Homepage:
- Size: 135 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Clutch
Clutch is a service registry and discovery component, that provides an infrastructure to publish and discover various resources, such as service proxies, HTTP endpoints, data sources.## Introduction
A service provider can:
* publish a service record
* un-publish a published record
* update the status of a published service (down, out of service…)A service consumer can:
* lookup services
* bind to a selected service and use it
* release the service once the consumer is done with it
* listen for arrival, departure and modification of services.## Quick Start
### add dependency:
```xmlcom.dinstone.clutch
clutch-zookeeper
1.1.0```
### service registry
```java
ZookeeperRegistryConfig config = new ZookeeperRegistryConfig().setZookeeperNodes("localhost:2181");
ZookeeperServiceRegistry registry = new ZookeeperServiceRegistry(config);
ServiceDescription description = new ServiceDescription();
String serviceName = "TestService";
description.setName(serviceName);
description.setId("service-provider-" + System.currentTimeMillis());
description.setHost("localhost");
description.setPort(80);
registry.register(description);
```
### service discovery
```java
ZookeeperRegistryConfig config = new ZookeeperRegistryConfig().setZookeeperNodes("localhost:2181");
ZookeeperServiceDiscovery discovery = new ZookeeperServiceDiscovery(config);
ServiceDescription description = new ServiceDescription();
String serviceName = "TestService";
description.setName(serviceName);
description.setId("service-consumer-1");
description.setHost("localhost");
description.setPort(0);discovery.listen(description);
List plist = discovery.discovery(serviceName, null);
for (ServiceDescription psd : plist) {
System.out.println(psd);
}
```