{"id":20677778,"url":"https://github.com/clivern/hippo","last_synced_at":"2025-04-05T03:11:18.308Z","repository":{"id":49105363,"uuid":"186064581","full_name":"Clivern/Hippo","owner":"Clivern","description":"💨A well crafted go packages that help you build robust, reliable, maintainable microservices.","archived":false,"fork":false,"pushed_at":"2025-03-05T17:30:04.000Z","size":116,"stargazers_count":145,"open_issues_count":8,"forks_count":7,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-04-03T23:34:27.018Z","etag":null,"topics":["asynchronous","consul","golang","logging","message-queue","microservices","rabbitmq","redis","service-discovery","toolkit"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Clivern.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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":"2019-05-10T23:05:00.000Z","updated_at":"2025-04-02T21:44:32.000Z","dependencies_parsed_at":"2023-01-23T10:01:10.662Z","dependency_job_id":"8751a32f-f23f-41c9-9d6f-de5fceb1168b","html_url":"https://github.com/Clivern/Hippo","commit_stats":{"total_commits":110,"total_committers":2,"mean_commits":55.0,"dds":0.0636363636363636,"last_synced_commit":"499ece4ed4c7ec3ca20a32222d7e37bd558528fb"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Clivern%2FHippo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Clivern%2FHippo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Clivern%2FHippo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Clivern%2FHippo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Clivern","download_url":"https://codeload.github.com/Clivern/Hippo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247280272,"owners_count":20912967,"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":["asynchronous","consul","golang","logging","message-queue","microservices","rabbitmq","redis","service-discovery","toolkit"],"created_at":"2024-11-16T21:17:06.059Z","updated_at":"2025-04-05T03:11:18.291Z","avatar_url":"https://github.com/Clivern.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n    \u003cimg alt=\"Hippo Logo\" src=\"https://raw.githubusercontent.com/Clivern/Hippo/master/assets/img/logo.png\" height=\"100\" /\u003e\n    \u003ch3 align=\"center\"\u003eHippo\u003c/h3\u003e\n    \u003cp align=\"center\"\u003eA Microservices Toolkit.\u003c/p\u003e\n    \u003cp align=\"center\"\u003e\n        \u003ca href=\"https://godoc.org/github.com/clivern/hippo\"\u003e\u003cimg src=\"https://godoc.org/github.com/clivern/hippo?status.svg\"\u003e\u003c/a\u003e\n        \u003ca href=\"https://travis-ci.org/Clivern/Hippo\"\u003e\u003cimg src=\"https://travis-ci.org/Clivern/Hippo.svg?branch=master\"\u003e\u003c/a\u003e\n        \u003ca href=\"https://github.com/Clivern/Hippo/releases\"\u003e\u003cimg src=\"https://img.shields.io/badge/Version-1.5.2-red.svg\"\u003e\u003c/a\u003e\n        \u003ca href=\"https://goreportcard.com/report/github.com/Clivern/Hippo\"\u003e\u003cimg src=\"https://goreportcard.com/badge/github.com/Clivern/Hippo?v=1.0.0\"\u003e\u003c/a\u003e\n        \u003ca href=\"https://github.com/Clivern/Hippo/blob/master/LICENSE\"\u003e\u003cimg src=\"https://img.shields.io/badge/LICENSE-MIT-orange.svg\"\u003e\u003c/a\u003e\n    \u003c/p\u003e\n\u003c/p\u003e\n\nHippo is a collection of well crafted go packages that help you build robust, reliable, maintainable microservices. It is not a full-fledged framework with lot of magic, predefined architecture, specific patterns and bullshit opinions so you will be the one behind the wheel.\n\nIt provides libraries to implement components for service discovery, async jobs, authentication, authorization, logging, caching, metrics, tracing, rate-limiting...etc which are essential requirements for running microservices in production.\n\n## Documentation\n\n### Installation:\n\n```golang\ngo get -u github.com/clivern/hippo\n```\n```golang\nimport (\n    \"github.com/clivern/hippo\"\n)\n```\n\n### Components:\n\n**HTTP Requests Component**\n\n```golang\n\nhttpClient := hippo.NewHTTPClient()\n\n// Get Request\nresponse, err := httpClient.Get(\n    \"https://httpbin.org/get\",\n    map[string]string{\"url_arg_key\": \"url_arg_value\"},\n    map[string]string{\"header_key\": \"header_value\"},\n)\n\n// Delete Request\nresponse, err := httpClient.Delete(\n    \"https://httpbin.org/delete\",\n    map[string]string{\"url_arg_key\": \"url_arg_value\"},\n    map[string]string{\"header_key\": \"header_value\"},\n)\n\n// Post Request\nresponse, err := httpClient.Post(\n    \"https://httpbin.org/post\",\n    `{\"RequestBodyKey\":\"RequestBodyValue\"}`,\n    map[string]string{\"url_arg_key\": \"url_arg_value\"},\n    map[string]string{\"header_key\": \"header_value\"},\n)\n\n// Put Request\nresponse, err := httpClient.Put(\n    \"https://httpbin.org/put\",\n    `{\"RequestBodyKey\":\"RequestBodyValue\"}`,\n    map[string]string{\"url_arg_key\": \"url_arg_value\"},\n    map[string]string{\"header_key\": \"header_value\"},\n)\n\n// ....\n\nstatusCode := httpClient.GetStatusCode(response)\nresponseBody, err := httpClient.ToString(response)\n```\n\n**Cache/Redis Component**\n\n```golang\ndriver := hippo.NewRedisDriver(\"localhost:6379\", \"password\", 0)\n\n// connect to redis server\nok, err := driver.Connect()\n// ping check\nok, err = driver.Ping()\n\n// set an item\nok, err = driver.Set(\"app_name\", \"Hippo\", 0)\n// check if exists\nok, err = driver.Exists(\"app_name\")\n// get value\nvalue, err := driver.Get(\"app_name\")\n// delete an item\ncount, err := driver.Del(\"app_name\")\n\n// hash set\nok, err = driver.HSet(\"configs\", \"app_name\", \"Hippo\")\n// check if item on a hash\nok, err = driver.HExists(\"configs\", \"app_name\")\n// get item from a hash\nvalue, err = driver.HGet(\"configs\", \"app_name\")\n// hash length\ncount, err = driver.HLen(\"configs\")\n// delete item from a hash\ncount, err = driver.HDel(\"configs\", \"app_name\")\n// clear the hash\ncount, err = driver.HTruncate(\"configs\")\n\n// Pub/Sub\ndriver.Publish(\"hippo\", \"Hello\")\ndriver.Subscribe(\"hippo\", func(message hippo.Message) error {\n    // message.Channel\n    // message.Payload\n    return nil\n})\n```\n\n**Time Series/Graphite Component**\n\n```golang\nimport \"time\"\n\n\nmetric := hippo.NewMetric(\"hippo1.up\", \"23\", time.Now().Unix()) // Type is hippo.Metric\n\nmetrics := hippo.NewMetrics(\"hippo2.up\", \"35\", time.Now().Unix()) // type is []hippo.Metric\nmetrics = append(metrics, hippo.NewMetric(\"hippo2.down\", \"40\", time.Now().Unix()))\nmetrics = append(metrics, hippo.NewMetric(\"hippo2.error\", \"70\", time.Now().Unix()))\n\n// NewGraphite(protocol string, host string, port int, prefix string)\n// protocol can be tcp, udp or nop\n// prefix is a metric prefix\ngraphite := hippo.NewGraphite(\"tcp\", \"127.0.0.1\", 2003, \"\")\nerror := graphite.Connect()\n\nif error == nil{\n    // send one by one\n    graphite.SendMetric(metric)\n\n    // bulk send\n    graphite.SendMetrics(metrics)\n}\n````\n\n**System Stats Component**\n\n```golang\n// func NewSystemStats(enableCPU, enableMem, enableGC bool) *SystemStats {\nstats := hippo.NewSystemStats(true, true, true)\nstats.GetStats() // type map[string]uint64\n// map[cpu.cgo_calls:0 cpu.goroutines:1 mem.alloc:0....]\n```\n\n**Correlation ID Component**\n\n```golang\ncorrelation := hippo.NewCorrelation()\ncorrelation.UUIDv4()\n```\n\n**Workers Pool Component**\n\n```golang\nimport \"fmt\"\n\ntasks := []*hippo.Task{\n    hippo.NewTask(func() (string, error) {\n        fmt.Println(\"Task #1\")\n        return \"Result 1\", nil\n    }),\n    hippo.NewTask(func() (string, error) {\n        fmt.Println(\"Task #2\")\n        return \"Result 2\", nil\n    }),\n    hippo.NewTask(func() (string, error) {\n        fmt.Println(\"Task #3\")\n        return \"Result 3\", nil\n    }),\n}\n\n// hippo.NewWorkersPool(tasks []*Task, concurrency int) *WorkersPool\np := hippo.NewWorkersPool(tasks, 2)\np.Run()\n\nvar numErrors int\nfor _, task := range p.Tasks {\n    if task.Err != nil {\n        fmt.Println(task.Err)\n        numErrors++\n    } else {\n        fmt.Println(task.Result)\n    }\n    if numErrors \u003e= 10 {\n        fmt.Println(\"Too many errors.\")\n        break\n    }\n}\n````\n\n**Health Checker Component**\n\n```golang\nimport \"fmt\"\n\nhealthChecker := hippo.NewHealthChecker()\nhealthChecker.AddCheck(\"ping_check\", func() (bool, error){\n    return true, nil\n})\nhealthChecker.AddCheck(\"db_check\", func() (bool, error){\n    return false, fmt.Errorf(\"Database Down\")\n})\nhealthChecker.RunChecks()\n\nfmt.Println(healthChecker.ChecksStatus())\n// Output -\u003e DOWN\nfmt.Println(healthChecker.ChecksReport())\n// Output -\u003e [{\"id\":\"ping_check\",\"status\":\"UP\",\"error\":\"\",\"result\":true},{\"id\":\"db_check\",\"status\":\"DOWN\",\"error\":\"Database Down\",\"result\":false}] \u003cnil\u003e\n```\n```golang\nimport \"fmt\"\n\nhealthChecker := hippo.NewHealthChecker()\n\nhealthChecker.AddCheck(\"url_check\", func() (bool, error){\n    return hippo.HTTPCheck(\"httpbin_service\", \"https://httpbin.org/status/503\", map[string]string{}, map[string]string{})\n})\nhealthChecker.AddCheck(\"redis_check\", func() (bool, error){\n    return hippo.RedisCheck(\"redis_service\", \"localhost:6379\", \"\", 0)\n})\nhealthChecker.RunChecks()\n\nfmt.Println(healthChecker.ChecksStatus())\n// Outputs -\u003e DOWN\nfmt.Println(healthChecker.ChecksReport())\n// Outputs -\u003e [{\"id\":\"url_check\",\"status\":\"DOWN\",\"error\":\"Service httpbin_service is unavailable\",\"result\":false},{\"id\":\"redis_check\",\"status\":\"DOWN\",\"error\":\"Error while connecting redis_service: dial tcp [::1]:6379: connect: connection refused\",\"result\":false}] \u003cnil\u003e\n```\n\n**API Rate Limiting**\n\n```golang\n\nimport \"time\"\n\n// Create a limiter with a specific identifier(IP address or access token or username....etc)\n// NewCallerLimiter(identifier string, eventsRate rate.Limit, tokenBurst int) *rate.Limiter\nlimiter := hippo.NewCallerLimiter(\"10.10.10.10\", 100, 1)\nif limiter.Allow() == false {\n    // Don't allow access\n} else {\n    // Allow Access\n}\n\n\n// auto clean old clients (should run as background process)\n// CleanupCallers(cleanAfter time.Duration)\ngo func(){\n    for {\n        time.Sleep(60 * time.Second)\n        hippo.CleanupCallers(60)\n    }\n}()\n```\n\n**Logger Component**\n\n```golang\nlogger, _ := hippo.NewLogger(\"debug\", \"json\", []string{\"stdout\", \"/var/log/error.log\"})\n\nlogger.Info(\"Hello World!\")\nlogger.Debug(\"Hello World!\")\nlogger.Warn(\"Hello World!\")\nlogger.Error(\"Hello World!\")\n\ndefer logger.Sync()\n\n// check if path exists\nexists := hippo.PathExists(\"/var/log\")\n\n// check if file exists\nexists := hippo.FileExists(\"/var/log/error.log\")\n\n// check if dir exists\nexists := hippo.DirExists(\"/var/log\")\n\n// ensure that dir exists\nexists, err := hippo.EnsureDir(\"/var/log\", 755)\n```\n\n**Latency Tracker Component**\n\n```golang\nhttpClient := hippo.NewHTTPClient()\n\nlatency := hippo.NewLatencyTracker()\nlatency.NewAction(\"api.call\")\n\n// First HTTP Call\nstart := time.Now()\nhttpClient.Get(\n    \"https://httpbin.org/get\",\n    map[string]string{},\n    map[string]string{},\n)\nlatency.SetPoint(\"api.call\", start, time.Now())\n\n// Another HTTP Call\nlatency.SetStart(\"api.call\", time.Now())\nhttpClient.Get(\n    \"https://httpbin.org/get\",\n    map[string]string{},\n    map[string]string{},\n)\nlatency.SetEnd(\"api.call\", time.Now())\n\n// Now it will calculate the average\nfmt.Println(latency.GetLatency(\"api.call\"))\n// Output 486.217112ms \u003cnil\u003e\n```\n\n\n## Versioning\n\nFor transparency into our release cycle and in striving to maintain backward compatibility, Hippo is maintained under the [Semantic Versioning guidelines](https://semver.org/) and release process is predictable and business-friendly.\n\nSee the [Releases section of our GitHub project](https://github.com/clivern/hippo/releases) for changelogs for each release version of Hippo. It contains summaries of the most noteworthy changes made in each release.\n\n\n## Bug tracker\n\nIf you have any suggestions, bug reports, or annoyances please report them to our issue tracker at https://github.com/clivern/hippo/issues\n\n\n## Security Issues\n\nIf you discover a security vulnerability within Hippo, please send an email to [hello@clivern.com](mailto:hello@clivern.com)\n\n\n## Contributing\n\nWe are an open source, community-driven project so please feel free to join us. see the [contributing guidelines](CONTRIBUTING.md) for more details.\n\n\n## License\n\n© 2019, Clivern. Released under [MIT License](https://opensource.org/licenses/mit-license.php).\n\n**Hippo** is authored and maintained by [@Clivern](http://github.com/clivern).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclivern%2Fhippo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fclivern%2Fhippo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclivern%2Fhippo/lists"}