Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shivam-880/consul-scala-macro-annotations
Register microservices to Consul out of the box using Scala macro annotations
https://github.com/shivam-880/consul-scala-macro-annotations
annotations consul macros metaprogramming microservices scala
Last synced: 7 days ago
JSON representation
Register microservices to Consul out of the box using Scala macro annotations
- Host: GitHub
- URL: https://github.com/shivam-880/consul-scala-macro-annotations
- Owner: shivam-880
- License: mit
- Created: 2018-12-22T00:28:46.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2018-12-26T10:52:25.000Z (almost 6 years ago)
- Last Synced: 2024-10-08T19:03:53.458Z (28 days ago)
- Topics: annotations, consul, macros, metaprogramming, microservices, scala
- Language: Scala
- Homepage: http://www.shivamkapoor.com/blogs/technology/2018/12/22/register-microservices-to-consul-out-of-the-box-using-scala-macro-annotations/
- Size: 28.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# consul-scala-macro-annotations
## Start Consul
```
$ consul agent -config-file=config.consul.json &
```**config.consul.json**
```
{
"ui": true,
"retry_join": ["172.20.20.31"],
"advertise_addr": "172.20.20.1",
"data_dir": "/tmp/consul",
"disable_remote_exec": false,
"enable_script_checks": true
}
```
## Clone Repo
```
$ git clone [email protected]:codingkapoor/consul-scala-macro-annotations.git
```## Build Package
```
$ cd consul-scala-macro-annotations
$ sbt> project myservice
$ sbt> universal:packageBin
```## Start Service
```
$ cd consul-scala-macro-annotations/myservice/target/universal
$ unzip myservice-0.1.0-SNAPSHOT.zip
$ cd myservice-0.1.0-SNAPSHOT
$ bin/start.sh
$ tail -f logs/stdout.log
```## Direct browser `@localhost:8080`
Accessing root at @localhost:8080 should return following message.> Microservices can use `@EnableServiceDiscovery` macro-annotation to register themselves to Consul out of the box.
## Consul Health Checks
`curl http://localhost:8500/v1/health/checks/v0.1.0-SNAPSHOT_myservice?pretty`
### Healthy
```
[
{
"Node": "inblrlt-shivam",
"CheckID": "service:2fd993e4931427b89f1bc832a6192ee0",
"Name": "Service 'v0.1.0-SNAPSHOT_myService' check",
"Status": "passing",
"Notes": "",
"Output": "Sun Dec 23 20:37:06 IST 2018: MyService is running\n",
"ServiceID": "2fd993e4931427b89f1bc832a6192ee0",
"ServiceName": "v0.1.0-SNAPSHOT_myService",
"ServiceTags": [
"tag1",
"tag2"
],
"Definition": {},
"CreateIndex": 13070,
"ModifyIndex": 13102
}
]
```### Unhealthy
```
[
{
"Node": "inblrlt-shivam",
"CheckID": "service:2fd993e4931427b89f1bc832a6192ee0",
"Name": "Service 'v0.1.0-SNAPSHOT_myService' check",
"Status": "warning",
"Notes": "",
"Output": "Sun Dec 23 20:40:18 IST 2018: MyService is not running\n",
"ServiceID": "2fd993e4931427b89f1bc832a6192ee0",
"ServiceName": "v0.1.0-SNAPSHOT_myService",
"ServiceTags": [
"tag1",
"tag2"
],
"Definition": {},
"CreateIndex": 13070,
"ModifyIndex": 13124
}
]
```