{"id":20354347,"url":"https://github.com/hemerajs/go-hemera","last_synced_at":"2025-04-12T02:25:58.718Z","repository":{"id":57502625,"uuid":"99216248","full_name":"hemerajs/go-hemera","owner":"hemerajs","description":"🔬Writing reliable \u0026 fault-tolerant microservices with https://nats.io","archived":false,"fork":false,"pushed_at":"2018-03-27T15:37:46.000Z","size":70,"stargazers_count":16,"open_issues_count":0,"forks_count":5,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-12T02:25:51.878Z","etag":null,"topics":["golang","hemera","microservice","pattern-matching","rpc"],"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/hemerajs.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}},"created_at":"2017-08-03T09:36:14.000Z","updated_at":"2024-04-21T05:37:16.000Z","dependencies_parsed_at":"2022-09-13T07:02:03.246Z","dependency_job_id":null,"html_url":"https://github.com/hemerajs/go-hemera","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/hemerajs%2Fgo-hemera","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hemerajs%2Fgo-hemera/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hemerajs%2Fgo-hemera/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hemerajs%2Fgo-hemera/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hemerajs","download_url":"https://codeload.github.com/hemerajs/go-hemera/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248506480,"owners_count":21115435,"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":["golang","hemera","microservice","pattern-matching","rpc"],"created_at":"2024-11-14T23:08:18.393Z","updated_at":"2025-04-12T02:25:58.698Z","avatar_url":"https://github.com/hemerajs.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n\u003cimg src=\"https://hemerajs.github.io/hemera/img/hemera.png\" alt=\"Hemera\" style=\"max-width:100%;\"\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"http://travis-ci.org/hemerajs/go-hemera\"\u003e\u003cimg src=\"https://camo.githubusercontent.com/e63eeeaa28adaf0d6aa7abd5ca9d2dd1f2f7293d/68747470733a2f2f7472617669732d63692e6f72672f68656d6572616a732f676f2d68656d6572612e7376673f6272616e63683d6d6173746572\" alt=\"Build Status\" data-canonical-src=\"https://travis-ci.org/hemerajs/go-hemera.svg?branch=master\" style=\"max-width:100%;\"\u003e\u003c/a\u003e\n\u003ca href=\"http://opensource.org/licenses/MIT\"\u003e\u003cimg src=\"https://camo.githubusercontent.com/311762166ef25238116d3cadd22fcb6091edab98/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d626c75652e737667\" alt=\"License MIT\" data-canonical-src=\"https://img.shields.io/badge/License-MIT-blue.svg\" style=\"max-width:100%;\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\nA \u003ca href=\"https://golang.org/\"\u003eGo\u003c/a\u003e microservices toolkit for the \u003ca href=\"https://nats.io\"\u003eNATS messaging system\u003c/a\u003e\n\u003c/p\u003e\n\n**Status:** Experimental\n\n## Install\n\n```\ngo get ./..\ngo get github.com/nats-io/gnatsd/server\n```\n\n### Example\n```go\n\ntype MathPattern struct {\n\tTopic string\n\tCmd   string\n}\n\ntype RequestPattern struct {\n\tTopic    string\n\tCmd      string\n\tA        int\n\tB        int\n\tMeta     server.Meta\n\tDelegate server.Delegate\n}\n\ntype Response struct {\n\tResult int\n}\n\nnc, _ := nats.Connect(nats.DefaultURL)\n\nhemera, _ := server.CreateHemera(nc, server.Timeout(2000), server.IndexingStrategy(DepthIndexing)...)\n\n// Define the pattern of your action\npattern := MathPattern{Topic: \"math\", Cmd: \"add\"}\nhemera.Add(pattern, func(req *RequestPattern, reply server.Reply, context *server.Context) {\n\t// Build response\n\tresult := Response{Result: req.A + req.B}\n\t// Add meta informations\n\tcontext.Meta[\"key\"] = \"value\"\n\t// Send it back\n\treply.Send(result)\n})\n\n// Define the call of your RPC\nrequestPattern := RequestPattern{\n\tTopic: \"math\",\n\tCmd: \"add\",\n\tA: 1,\n\tB: 2,\n\tMeta: server.Meta{ \"Test\": 1 },\n\tDelegate: server.Delegate{ \"Test\": 2 },\n}\n\nres := \u0026Response{} // Pointer to struct\nctx := hemera.Act(requestPattern, res)\n\nres = \u0026Response{}\nctx = hemera.Act(requestPattern, res, ctx)\n\nlog.Printf(\"Response %+v\", res)\n```\n\n## Pattern matching\nWe implemented two indexing strategys\n- `depth order` match the entry with the most properties first.\n- `insertion order` match the entry with the least properties first. `(default)`\n\n## TODO\n- [X] Setup nats server for testing\n- [X] Implement Add and Act\n- [X] Create Context (trace, meta, delegate) structures\n- [X] Use tree for pattern indexing\n- [X] Support indexing by depth order\n- [X] Support indexing by insetion order\n- [X] Clean request pattern from none primitive values\n- [X] Meta \u0026 Delegate support\n- [X] Implement basic pattern matching (router)\n- [ ] Implement router `remove` method\n\n## Credits\n\n- [Bloomrun](https://github.com/mcollina/bloomrun) the pattern matching library for NodeJs\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhemerajs%2Fgo-hemera","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhemerajs%2Fgo-hemera","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhemerajs%2Fgo-hemera/lists"}