{"id":19492767,"url":"https://github.com/oatpp/oatpp-consul","last_synced_at":"2025-05-09T01:23:06.798Z","repository":{"id":36599658,"uuid":"139286659","full_name":"oatpp/oatpp-consul","owner":"oatpp","description":"oatpp client for consul","archived":false,"fork":false,"pushed_at":"2024-05-16T21:09:02.000Z","size":60,"stargazers_count":39,"open_issues_count":2,"forks_count":16,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-04-21T03:27:07.737Z","etag":null,"topics":["c-plus-plus","consul","cpp","oatpp"],"latest_commit_sha":null,"homepage":"https://oatpp.io/","language":"C++","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/oatpp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-06-30T23:14:39.000Z","updated_at":"2025-02-23T12:51:49.000Z","dependencies_parsed_at":"2024-11-07T00:40:21.010Z","dependency_job_id":null,"html_url":"https://github.com/oatpp/oatpp-consul","commit_stats":{"total_commits":53,"total_committers":4,"mean_commits":13.25,"dds":"0.16981132075471694","last_synced_commit":"cb8ef0fdefe6e2976422ba459c4ddbf3fab53dc5"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oatpp%2Foatpp-consul","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oatpp%2Foatpp-consul/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oatpp%2Foatpp-consul/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oatpp%2Foatpp-consul/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oatpp","download_url":"https://codeload.github.com/oatpp/oatpp-consul/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250822970,"owners_count":21492979,"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":["c-plus-plus","consul","cpp","oatpp"],"created_at":"2024-11-10T21:22:57.542Z","updated_at":"2025-05-09T01:23:06.775Z","avatar_url":"https://github.com/oatpp.png","language":"C++","readme":"# oatpp-consul [![Build Status](https://dev.azure.com/lganzzzo/lganzzzo/_apis/build/status/oatpp.oatpp-consul?branchName=master)](https://dev.azure.com/lganzzzo/lganzzzo/_build/latest?definitionId=7\u0026branchName=master)\n\n**oatpp-consul** - extension for [oatpp web framework](https://github.com/oatpp/oatpp).  \nIt provides Consul integration for oatpp applications.  \n\nSee more:\n- [Oatpp website](https://oatpp.io/)\n- [Oatpp Github repository](https://github.com/oatpp/oatpp)\n- [Consul API](https://www.consul.io/api/index.html)\n\n## APIs\n\n- [oatpp::consul::Client](https://github.com/oatpp/oatpp-consul/blob/master/Client.hpp) - Simple consul-KV API.\n- [oatpp::consul::rest::Client](https://github.com/oatpp/oatpp-consul/blob/master/rest/Client.hpp) - oatpp retrofit-like client for consul. Currently provides consul KV, Agent-Checks, Agent-Services API.\n\n## Example\n\nFor full example project see: [oatpp-consul example](https://github.com/oatpp/example-consul)\n\n### KV\n\n```c++\n\n#include \"oatpp-consul/Client.hpp\"\n\n...\n  \n  /* request executor should be previously initialized */\n  auto client = oatpp::consul::Client::createShared(requestExecutor);\n\n  /* put value */\n  client-\u003ekvPut(\"key1\", \"value1\");\n \n  /* get value */\n  auto value = client-\u003ekvGet(\"key1\");\n  \n  /* print value */\n  OATPP_LOGD(\"consul\", \"value='%s'\", value-\u003ec_str());\n  \n  /* get kv metadata */\n  auto meta = client-\u003ekvGetMetadata(\"key1\");\n  \n  /* decode and pring value from metadata */\n  OATPP_LOGD(\"consul\", \"value='%s'\", meta-\u003egetValueDecoded()-\u003ec_str());\n\n...\n\n```\n\n### Register Service\n\n```c++\n\n#include \"oatpp-consul/Client.hpp\"\n\n...\n  \n  /* request executor should be previously initialized */\n  auto client = oatpp::consul::Client::createShared(requestExecutor);\n  \n  /* get oatpp::consul::rest::Client */\n  auto restClient = client-\u003egetRestClient();\n  \n  auto checkPayload = oatpp::consul::rest::AgentCheckRegisterPayload::createShared();\n  checkPayload-\u003eserviceID = \"service_check_id\";\n  checkPayload-\u003ename = \"service_check_name\";\n  checkPayload-\u003enotes = \"Check on the MyService/Health endpoint\";\n  checkPayload-\u003ehttp = \"http://localhost:8000/check/health\";\n  checkPayload-\u003emethod = \"GET\";\n  checkPayload-\u003einterval = \"30s\";\n  checkPayload-\u003etimeout = \"15s\";\n  \n  auto payload = oatpp::consul::rest::AgentServiceRegisterPayload::createShared();\n  payload-\u003eid = \"service_id\";\n  payload-\u003ename = \"service_name\";\n  payload-\u003eport = 8000;\n  payload-\u003echeck = checkPayload;\n  \n  /* make API call */\n  auto response = restClient-\u003eagentServiceRegister(payload);\n  \n  OATPP_LOGD(\"consul\", \"response='%s'\", response-\u003ereadBodyToString()-\u003ec_str());\n  \n...\n```\n\n","funding_links":[],"categories":["C++"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foatpp%2Foatpp-consul","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foatpp%2Foatpp-consul","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foatpp%2Foatpp-consul/lists"}