{"id":13805866,"url":"https://github.com/smoketurner/dropwizard-consul","last_synced_at":"2025-05-13T21:31:44.975Z","repository":{"id":3620106,"uuid":"50309640","full_name":"smoketurner/dropwizard-consul","owner":"smoketurner","description":"Dropwizard Consul Bundle","archived":true,"fork":false,"pushed_at":"2023-03-27T23:50:49.000Z","size":3786,"stargazers_count":54,"open_issues_count":0,"forks_count":20,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-06-21T18:12:36.736Z","etag":null,"topics":["consul","dropwizard","dropwizard-consul","java"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/smoketurner.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null},"funding":{"github":"jplock","patreon":"jplock","open_collective":null,"ko_fi":null,"tidelift":null,"custom":null}},"created_at":"2016-01-24T21:41:29.000Z","updated_at":"2023-11-18T04:57:17.000Z","dependencies_parsed_at":"2023-01-13T13:00:16.832Z","dependency_job_id":null,"html_url":"https://github.com/smoketurner/dropwizard-consul","commit_stats":null,"previous_names":[],"tags_count":52,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smoketurner%2Fdropwizard-consul","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smoketurner%2Fdropwizard-consul/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smoketurner%2Fdropwizard-consul/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smoketurner%2Fdropwizard-consul/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/smoketurner","download_url":"https://codeload.github.com/smoketurner/dropwizard-consul/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":213870459,"owners_count":15650178,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["consul","dropwizard","dropwizard-consul","java"],"created_at":"2024-08-04T01:01:05.735Z","updated_at":"2024-08-04T01:05:25.225Z","avatar_url":"https://github.com/smoketurner.png","language":"Java","funding_links":["https://github.com/sponsors/jplock","https://patreon.com/jplock","https://www.patreon.com/bePatron?u=9567343"],"categories":["Open Source"],"sub_categories":["Eclipse"],"readme":"Dropwizard Consul Bundle\n========================\n[![Build Status](https://travis-ci.org/smoketurner/dropwizard-consul.svg?branch=master)](https://travis-ci.org/smoketurner/dropwizard-consul)\n[![Maven Central](https://img.shields.io/maven-central/v/com.smoketurner.dropwizard/dropwizard-consul.svg?style=flat-square)](https://maven-badges.herokuapp.com/maven-central/com.smoketurner.dropwizard/dropwizard-consul/)\n[![GitHub license](https://img.shields.io/github/license/smoketurner/dropwizard-consul.svg?style=flat-square)](https://github.com/smoketurner/dropwizard-consul/tree/master)\n[![Become a Patron](https://img.shields.io/badge/Patron-Patreon-red.svg)](https://www.patreon.com/bePatron?u=9567343)\n\nA bundle for using [Consul](https://consul.io) in Dropwizard applications. Features:\n\n* Integrated client-side load balancer based on [Ribbon](https://github.com/netflix/ribbon)\n* Dropwizard health check that monitors reachablility of Consul\n* The Dropwizard service is registered as a Consul service with a Consul-side health check querying the Dropwizard [health check](https://www.dropwizard.io/en/latest/manual/core.html#health-checks)\n* Ability to resolve [configuration](https://www.dropwizard.io/en/latest/manual/core.html#configuration) properties from Consul's KV store\n* Admin task to toggle Consul's [maintenance](https://www.consul.io/api/agent.html#enable-maintenance-mode) mode\n\nDependency Info\n---------------\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.smoketurner.dropwizard\u003c/groupId\u003e\n    \u003cartifactId\u003econsul-core\u003c/artifactId\u003e\n    \u003cversion\u003e2.0.7-1\u003c/version\u003e\n\u003c/dependency\u003e\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.smoketurner.dropwizard\u003c/groupId\u003e\n    \u003cartifactId\u003econsul-ribbon\u003c/artifactId\u003e\n    \u003cversion\u003e2.0.7-1\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nUsage\n-----\nAdd a `ConsulBundle` to your [Application](https://javadoc.io/doc/io.dropwizard/dropwizard-project/latest/io/dropwizard/Application.html) class.\n\n```java\n@Override\npublic void initialize(Bootstrap\u003cMyConfiguration\u003e bootstrap) {\n    // ...\n    bootstrap.addBundle(new ConsulBundle\u003cMyConfiguration\u003e(getName()) {\n        @Override\n        public ConsulFactory getConsulFactory(MyConfiguration configuration) {\n            return configuration.getConsulFactory();\n        }\n    });\n}\n```\n\nThe bundle also includes a `ConsulSubsitutor` to retrieve configuration values from the Consul KV store. You can define settings in your YAML configuration file:\n\n```\ntemplate: ${helloworld/template:-Hello, %s!}\ndefaultName: ${helloworld/defaultName:-Stranger}\n```\n\nThe setting with the path `helloworld/template` will be looked up in the KV store and will be replaced in the configuration file when the application is started. You can specify a default value after the `:-`. This currently does not support dynamically updating values in a running Dropwizard application.\n\nConfiguration\n-------------\nFor configuring the Consul connection, there is a `ConsulFactory`:\n\n```yaml\nconsul:\n  # Optional properties\n  # endpoint for consul (defaults to localhost:8500)\n  endpoint: localhost:8500\n  # service port\n  servicePort: 8080\n  # check interval frequency\n  checkInterval: 1 second\n```\n\nExample Application\n-------------------\nThis bundle includes a modified version of the `HelloWorldApplication` from Dropwizard's [Getting Started](https://www.dropwizard.io/1.3.12/docs/getting-started.html) documentation.\n\nYou can execute this application by first starting Consul on your local machine then running:\n\n```\nmvn clean package\njava -jar consul-example/target/consul-example-2.0.7-4-SNAPSHOT.jar server consul-example/hello-world.yml\n```\n\nThis will start the application on port `8080` (admin port `8180`). This application demonstrations the following Consul integration points:\n\n- The application is registered as a service with Consul (with the [service port](https://www.consul.io/docs/agent/services.html) set to the applicationConnectors port in the configuration file.\n- The application will lookup any variables in the configuration file from Consul upon startup (it defaults to connecting to a Consul agent running on `localhost:8500` for this functionality)\n- The application exposes an additional HTTP endpoint for querying Consul for available healthy services:\n```\ncurl -X GET localhost:8080/consul/hello-world -i\nHTTP/1.1 200 OK\nDate: Mon, 25 Jan 2016 03:42:10 GMT\nContent-Type: application/json\nVary: Accept-Encoding\nContent-Length: 870\n\n[\n    {\n        \"Node\": {\n            \"Node\": \"mac\",\n            \"Address\": \"192.168.1.100\",\n            \"Datacenter\": \"dc1\",\n            \"TaggedAddresses\": {\n                \"wan\": \"192.168.1.100\",\n                \"lan\": \"192.168.1.100\"\n            },\n            \"Meta\": {\n                \"consul-network-segment\": \"\"\n            }\n        },\n        \"Service\": {\n            \"ID\": \"test123\",\n            \"Service\": \"hello-world\",\n            \"EnableTagOverride\": false,\n            \"Tags\": [],\n            \"Address\": \"\",\n            \"Meta\": {\n                \"scheme\": \"http\"\n            },\n            \"Port\": 8080,\n            \"Weights\": {\n                \"Passing\": 1,\n                \"Warning\": 1\n            }\n        },\n        \"Checks\": [\n            {\n                \"Node\": \"mac\",\n                \"CheckID\": \"serfHealth\",\n                \"Name\": \"Serf Health Status\",\n                \"Status\": \"passing\",\n                \"Notes\": \"\",\n                \"Output\": \"Agent alive and reachable\",\n                \"ServiceID\": \"\",\n                \"ServiceName\": \"\",\n                \"ServiceTags\": []\n            },\n            {\n                \"Node\": \"mac\",\n                \"CheckID\": \"service:test123\",\n                \"Name\": \"Service 'hello-world' check\",\n                \"Status\": \"passing\",\n                \"Notes\": \"\",\n                \"Output\": \"HTTP GET http:\\/\\/127.0.0.1:8180\\/healthcheck: 200 OK Output: {\\\"consul\\\":{\\\"healthy\\\":true},\\\"deadlocks\\\":{\\\"healthy\\\":true}}\",\n                \"ServiceID\": \"test123\",\n                \"ServiceName\": \"hello-world\",\n                \"ServiceTags\": []\n            }\n        ]\n    }\n]\n```\n- The application will periodically checkin with Consul every second to notify the service check that it is still alive\n- Upon shutdown, the application will deregister itself from Consul\n\nCredits\n-------\nThis bundle was inspired by an older bundle (Dropwizard 0.6.2) that [Chris Gray](https://github.com/chrisgray) created at https://github.com/chrisgray/dropwizard-consul. I also incorporated the configuration provider changes from https://github.com/remmelt/dropwizard-consul-config-provider\n\nSupport\n-------\nPlease file bug reports and feature requests in [GitHub issues](https://github.com/smoketurner/dropwizard-consul/issues).\n\nLicense\n-------\nCopyright (c) 2020 Smoke Turner, LLC\n\nThis library is licensed under the Apache License, Version 2.0.\n\nSee http://www.apache.org/licenses/LICENSE-2.0.html or the [LICENSE](LICENSE) file in this repository for the full license text.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmoketurner%2Fdropwizard-consul","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsmoketurner%2Fdropwizard-consul","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmoketurner%2Fdropwizard-consul/lists"}