{"id":22884912,"url":"https://github.com/jquiterio/mhub","last_synced_at":"2026-04-28T17:02:45.375Z","repository":{"id":38413416,"uuid":"439835466","full_name":"jquiterio/mhub","owner":"jquiterio","description":"A Non-Standard Message Hub","archived":false,"fork":false,"pushed_at":"2023-02-25T11:34:15.000Z","size":21693,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-16T14:18:15.509Z","etag":null,"topics":["http","hub","message","pubsub","redis"],"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/jquiterio.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}},"created_at":"2021-12-19T10:36:05.000Z","updated_at":"2023-09-16T19:47:03.000Z","dependencies_parsed_at":"2023-07-12T19:01:28.060Z","dependency_job_id":null,"html_url":"https://github.com/jquiterio/mhub","commit_stats":null,"previous_names":["jquiterio/go-spb"],"tags_count":19,"template":false,"template_full_name":null,"purl":"pkg:github/jquiterio/mhub","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jquiterio%2Fmhub","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jquiterio%2Fmhub/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jquiterio%2Fmhub/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jquiterio%2Fmhub/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jquiterio","download_url":"https://codeload.github.com/jquiterio/mhub/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jquiterio%2Fmhub/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32390067,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-28T14:34:11.604Z","status":"ssl_error","status_checked_at":"2026-04-28T14:32:37.009Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["http","hub","message","pubsub","redis"],"created_at":"2024-12-13T19:29:11.923Z","updated_at":"2026-04-28T17:02:45.348Z","avatar_url":"https://github.com/jquiterio.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mHub - simple message hub\n\n---\n\n### Convention\n\n\n***Topic***: string \n\n***Message***: \n\nstring with the following format `action.object_name.object_id`\n\n`action`: can be any action ex.: `create`, `list`, `update`, `delete`, `sync`, etc.\n\n`object_name`: is the object name or group of objects, ex: `mug` or `cat`\n\n`object_id`: if action affects a particular object id, is the id of that object, otherwise if `null` or even nothing.\n\n### Use Case\n\n![usecase](usecase.png)\n\n\n### Requirements\n\nA running redis instance [check here how to start](https://redis.io/topics/quickstart)\n\n### Quick Start\n\n#### Server\n\n```\ngo get -u github.com/jquiterio/mhub\ngo build github.com/jquiterio/mhub -o mhub\n./mhub\n```\n\nthis assume that you have a running REDIS SEVER on localhost:6379.\n\nit will listen on port 8083 at localhost address.\n\n#### Client\n\n```go\n\nimport mhubClient \"github.com/jquiterio/mhubclient-go\"\n\n\nfunc main() {\n\t\t// Create a Client\n\t\tsrvAddr := \"localhost:8083\" \n\t\tisSecure := false\n  \tcli, err := mhubClient.NewHubClient(srvAddr, isSecure)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\t// Define what to do with Topic messages that you'll receive from http stream.\n\tcli.MessageHandler = func(msg interface{}) error {\n\t\tfmt.Println(msg) // in this case: just print them to stdout\n\t\treturn nil\n\t}\n\t// Get the auto-generated Client ID. It's great for debug purpose\n\t// You can then use the ClientID in a variable $CLIENTID for debug purpose to post like:\n\t// curl -X POST -H \"X-Subscriber-ID: $CLIENTID\" \\\n\t// http://localhost:8083/publish/test \\\n\t// -d '{\"msgType\":\"publish\",\"topic\":\"test1\",\"msg\":\"yay!\"}'\n\t//fmt.Println(cli.ClientID)\n\n\t// Add a New Topic\n\t// This will add a Topic to the Client (local information)\n\tif ok := cli.AddTopic([]string{\"test1\", \"test2\"}); !ok {\n\t\t// do something if not OK\n\t\t// not that you'll not receive any messages if not declare topics here\n\t\t// like fmt.println(\"failed to add topics\")\n\t}\n\t// Subscribe the client with topics you have added\n\t// This will subscribe cli.ClientID to topics 'test1' and 'test2'.\n\tif ok := cli.Subscribe(); !ok {\n\t\tpanic(\"failed to subscribe\")\n\t}\n\t// Client can also publish to hub, so other clients can get messages\n\t// This will publish to topic 'test1'\n\tcli.Publish(\"test1\", \"Yay!\")\n\t// Me() is additional information you can get from Hub about this client.\n\tcli.Me()\n\t// This will retried a http stream messages to be parsed by cli.MessageHandler\n\tcli.GetMessages()\n}\n```\n\n### Advanced Usage\n\n#### Generate Certificates\n\nif `cli, err := mhubClient.NewHubClient(srvAddr, true)` you have to create a tls certificate to use by the server and the client.\n\n```bash\nmkdir ~/mhub_certificates\ncd ~/mhub_certificates\n\ncp $GOPATH/src/github.com/jquiterio/mhub/gencert.sh .\n./gencert.sh localhost\n```\n\n#### Start the message Hub Server\n\n##### Option 1: Build and start\n\n```bash\ngo build github.com/jquiterio/mhub -o mhub\n./mhub #for default values\n# OR\nHUB_ADDR=localhost HUB_PORT=8083 REDIS_ADDR=localhost:6379 REDIS_PASSWD=\"\" ./mhub\n```\n\n##### Option 2: Instantiate Hub Server in your project\n\n```go\nimport \"github.com/jquiterio/mhub/server\"\nfunc main(){\n\thub := mhub.NewHub()\n\t// Possible actions/configurations:\n\t// hub.Subscribers = append(hub.Subscribers, mhub.Subscriber{ID: \"FC27C37A-59C5-4913-976C-2CB6C55781A1\", Topics: []string{\"topic1\", \"topic2\"}})\n\t// hub.Topics = append(hub.Topics, \"topic1\")\n\t// hub.Topics = append(hub.Topics, \"topic2\")\n\t// hub.Registry = redis.NewClient(\u0026redis.Options{Addr: \"localhost:6379\", DB: 0})\n\n\t// work with mhub instance or Just start it\n\t// it will serve on port 8083\n\t// hub.Serve()\n\n\t// Possible Environment Variables for Hub:\n\t// HUB_ADDR: hostname or ip address\n\t// HUB_PORT: port number\n\t// HUB_SECURE: true or false // will configure tls and ./gencerts.sh can help to generate certificates\n\t// Note that, if HUB_SECURE is true, client must also be secure ex: cli.NewClient(\"localhost:8083\", true)\n}\n```\n\n##### Option 3: Docker\n\nTBA\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjquiterio%2Fmhub","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjquiterio%2Fmhub","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjquiterio%2Fmhub/lists"}