{"id":18794709,"url":"https://github.com/cneira/taraxacum","last_synced_at":"2025-04-13T15:25:58.272Z","repository":{"id":95938788,"uuid":"84246824","full_name":"cneira/Taraxacum","owner":"cneira","description":"Taraxacum is a  C++-11 Microservices Framework with focus in an easy to use API ","archived":false,"fork":false,"pushed_at":"2017-04-07T14:42:32.000Z","size":2648,"stargazers_count":5,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-27T06:22:20.439Z","etag":null,"topics":["cpp11","microservice","pistache","rapidjson"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cneira.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":"2017-03-07T21:15:51.000Z","updated_at":"2023-12-27T01:03:13.000Z","dependencies_parsed_at":null,"dependency_job_id":"260576ea-21da-4579-85a0-83f992dcac7f","html_url":"https://github.com/cneira/Taraxacum","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cneira%2FTaraxacum","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cneira%2FTaraxacum/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cneira%2FTaraxacum/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cneira%2FTaraxacum/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cneira","download_url":"https://codeload.github.com/cneira/Taraxacum/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248734194,"owners_count":21153166,"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":["cpp11","microservice","pistache","rapidjson"],"created_at":"2024-11-07T21:30:37.607Z","updated_at":"2025-04-13T15:25:58.235Z","avatar_url":"https://github.com/cneira.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"![](Taraxacum.jpg)\n\n# Taraxacum\n     \n  [![Build Status](https://travis-ci.org/cneira/Taraxacum.svg?branch=master)](https://travis-ci.org/cneira/Taraxacum)   \n     \nIs a framework for creating microservices written in pure C++-11.\nIt aims to be a fast, full featured and with an easy to use API implementation for microservices.\nIt's sort of inspired on [Go-Kit](https://gokit.io/) for microservices. It uses the excellent frameworks pistache for REST and HTTP and rapidjson. \n\n\nNote that this project it is under active developing, doesn't have a stable interface and was not tested enough. So if you are looking for something stable and ready to be used in production then it's better to come back later or help me growing this project to the quality level you need.\n\n# Dependencies\n\n* Pistache  http://pistache.io/\n\n* RapidJson http://rapidjson.org/\n\n\n# Installation\n```bash\ngit clone  https://github.com/cneira/Taraxacum.git\ncd  Taraxacum \u0026\u0026 mkdir build \u0026\u0026 cd build \u0026\u0026 cmake ../ \u0026\u0026 make \u0026\u0026 sudo make install\n```\n\n# Usage\n\nTaraxacum follows the [Decorator Patern](https://en.wikipedia.org/wiki/Decorator_pattern).\nIn Taraxacum Decorators are just called Providers to reflect for example that we could add a graphite provider to include metrics.\n\n## Instanciating a microservice\n To instanciate a microservice we use the template AddProviders_shared template.\n \n ```cpp\n   std::shared_ptr\u003cUservice_Interface\u003e microservice =  AddProviders_shared\u003cMicroservice\u003cmicroservices::Service\u003e\u003e();\n   microservice-\u003eAnswer(8080,2);\n ```\n## Add Providers\n```cpp\nusing namespace Taraxacum;\n // Here we are adding a CircuitBreaker and a Logging Providers\n    std::shared_ptr\u003cUservice_Interface\u003e usvc =\n         AddProviders_shared\u003cCircuitBreaker, Logging,\n                             Microservice\u003cmicroservices::Service\u003e\u003e();\n     // Start answering requests on port 9030 using 2 threads\n     usvc-\u003eAnswer(9030, 2);\n     // called some providers\n     usvc-\u003eCircuit_Break();\n     usvc-\u003eLog();\n```\n\n# Examples\n\n## Simple micro service\nThis microservice just returns the string \"Hello Hello\" and the  http request received \n```cpp\n#include \"Taraxacum/Microservice.h\"\nusing namespace Taraxacum;\nstruct Service {\n  const std::string operator()(std::string http_request) {\n    return \"Hello Hello \" + http_request;\n  };\n\n\nint main() {\n   std::shared_ptr\u003cUservice_Interface\u003e usvc =\n        AddProviders_shared\u003cCircuitBreaker, Logging,\n                            Microservice\u003cService\u003e\u003e();\n    // Start answering requests on port 9030 using 2 threads\n    usvc-\u003eAnswer(9030, 2);\n}\n```\n\n## Rest Micro service\nIf you need to consume and output json,rapidjson is used, there is Rest microservice template.\n\n```cpp \nusing namespace Taraxacum;\n// The same but using the RestService template\n\nstruct Restsvc {\n  void operator()(rapidjson::Document \u0026Doc) {\n    rapidjson::Value \u0026s = Doc[\"stars\"];\n    s.SetInt(s.GetInt() + 1);\n  }\n};\n\n\nint main() {\n  // Now Using a template.\n  //  The RestService template takes care for you json parsing validation.\n  std::shared_ptr\u003cUservice_Interface\u003e usvc_rest =\n      AddProviders_shared\u003cCircuitBreaker, Logging,\n                          Microservice\u003cRestService\u003cRestsvc\u003e\u003e\u003e();\nreturn 0;                          \n}\n```\n## Micro service Routing\nThere is a template where you need to have routes on your microservices\n```cpp\n\nusing namespace Taraxacum;\nnamespace uRest {\n    void biz(const Rest::Request \u0026request, Http::ResponseWriter response) {\n        response.send(Http::Code::Ok, \"Here is routing\");\n    }\n}\nint main() {\nstd::shared_ptr\u003cUservice_Interface\u003e usvc_rest_with_routing =\n      AddProviders_shared\u003cCircuitBreaker, Logging,\n                          Routing_Microservice\u003cuRest::biz\u003e\u003e();\n\n  // Start answering requets on port 9031, using 2 threads and on the route\n  //  \"/stars/response\", and HTTP method : GET, POST, PUT, DELETE\n\n  usvc_rest_with_routing-\u003eAnswer(9032, 2, \"/stars/response\", HTTP_METHOD::GET);\n  return 0;\n}\n```\n## Shell command micro service\n This will create a micro service that expects a config.json with the following format { \"cmd\": \\\u003cyour shell command\u003e }\n and will respond a json with the format {\"output_cmd\": \"\\\u003cshell command output\u003e\" ,\"err\": \"\\\u003cerror message if any\u003e\" }\n```cpp\n using namespace Taraxacum;\n  std::shared_ptr\u003cUservice_Interface\u003e usvc_rest_with_routing =\n      AddProviders_shared\u003cRouting_Microservice\u003cuServices::ShellCmd\u003e\u003e();\n\n  std::cout\n      \u003c\u003c \"Start answering requets on port 9032, using 2 threads and on \"\n         \"the route \\\"/services/script1\\\" using http GET, this will \"\n         \"execute the command specified in config.json and return the result\"\n      \u003c\u003c std::endl;\n\n  usvc_rest_with_routing-\u003eAnswer(9032, 2, \"/services/script1\",\n                                 HTTP_METHOD::GET);\n\n```\n\n## Performance tests\n\nFor the Shellcmd micro services the results are the following\n\nusing apache benchmark tool with the following parameters:\n```bash\n\n$  ab -n 2000  -k -v 4 -c 200   http://127.0.0.1:9032/services/script1\n{ \"cmd\":\" Linux 6fd4b134-4c25-cbab-9982-c292a79c2f04 4.3.0 BrandZ virtual linux x86_64 x86_64 x86_64 GNU/Linux\", \"err\":\"\"}\nLOG: Response code = 200\n\n\nCompleted 2000 requests\nFinished 2000 requests\n\n\nServer Software:\nServer Hostname:        127.0.0.1\nServer Port:            9032\n\nDocument Path:          /services/script1\nDocument Length:        122 bytes\n\nConcurrency Level:      200\nTime taken for tests:   9.527 seconds\nComplete requests:      2000\nFailed requests:        0\nKeep-Alive requests:    2000\nTotal transferred:      372000 bytes\nHTML transferred:       244000 bytes\nRequests per second:    209.92 [#/sec] (mean)\nTime per request:       952.726 [ms] (mean)\nTime per request:       4.764 [ms] (mean, across all concurrent requests)\nTransfer rate:          38.13 [Kbytes/sec] received\n\nConnection Times (ms)\n              min  mean[+/-sd] median   max\nConnect:        0    0   0.9      0       6\nProcessing:     8  892 224.5    907    1198\nWaiting:        8  892 224.5    907    1198\nTotal:          8  892 223.9    907    1198\n\nPercentage of the requests served within a certain time (ms)\n  50%    907\n  66%   1004\n  75%   1045\n  80%   1065\n  90%   1148\n  95%   1170\n  98%   1191\n  99%   1195\n 100%   1198 (longest request)\n\n```\n\n\n\n## TODO\n\n  - [ ]  Check current design and refactor \n  - [X]  Define which providers are not needed \n  - [ ]  Remove/Add Providers \n  - [X]  Stabilize API\n  - [ ]  Stress test microservices\n  - [ ]  Implement API gateway pattern\n  - [ ]  Add Observability to micro services\n  - [ ]  Create more examples\n \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcneira%2Ftaraxacum","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcneira%2Ftaraxacum","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcneira%2Ftaraxacum/lists"}