{"id":36804981,"url":"https://github.com/nqd/mq","last_synced_at":"2026-01-12T13:38:32.037Z","repository":{"id":57704757,"uuid":"191190735","full_name":"nqd/mq","owner":"nqd","description":"A Golang message queue that does struct encoding and matches topics like  RabbitMQ.","archived":false,"fork":false,"pushed_at":"2019-07-08T14:46:27.000Z","size":27,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-06-19T16:47:12.780Z","etag":null,"topics":["golang","matching","message","queue","topic"],"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/nqd.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-06-10T15:06:26.000Z","updated_at":"2024-02-08T08:03:31.000Z","dependencies_parsed_at":"2022-09-26T21:20:18.312Z","dependency_job_id":null,"html_url":"https://github.com/nqd/mq","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/nqd/mq","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nqd%2Fmq","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nqd%2Fmq/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nqd%2Fmq/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nqd%2Fmq/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nqd","download_url":"https://codeload.github.com/nqd/mq/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nqd%2Fmq/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28339299,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-12T12:22:26.515Z","status":"ssl_error","status_checked_at":"2026-01-12T12:22:10.856Z","response_time":98,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: 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":["golang","matching","message","queue","topic"],"created_at":"2026-01-12T13:38:31.963Z","updated_at":"2026-01-12T13:38:32.021Z","avatar_url":"https://github.com/nqd.png","language":"Go","readme":"# MQ [![Build Status](https://secure.travis-ci.org/nqd/mq.png?branch=master)](http://travis-ci.org/nqd/mq)\n\nA Golang message queue that does struct encoding and matches topics like  RabbitMQ.\n\n## Installation\n\n## Basic Usage\n\n```{go}\nimport \"github.com/nqd/mq\"\n\nm := mq.NewMQ()\n\n// Async subscription\nsub, err := m.Subscribe(\"foo\", func(m []byte) {\n    fmt.Printf(\"Received a message %s\\n\", string(m))\n})\n// ...\nerr := m.Publish(\"foo\", []byte(\"hello world\"))\n\n// MQ with a Golang struct\ntype todo struct {\n    Title string\n    Finish    bool\n}\n\nsub, err := m.Subscribe(\"bar\", func(t *todo) {\n    log.Printf(\"received a todo %+v\\n\", t)\n})\n// ...\nmtd := \u0026todo{\n    Title:  \"get mq work\",\n    Finish: false,\n}\nerr := m.Publish(\"bar\", mtd)\n// ...\n\n// Unsubscribe\nerr := sub.Unsubscribe()\n\n// Close the MQ\nm.Close()\n```\n\n## Wildcard subscription\n\nMQ supports the use of wildcard with amqp-like topics:\n\n- topic is splitted according to delimiter, default `.`,\n- wildcard one (default `*`) matches exactly one word,\n- and wildcard some (default `#`) matches zero or many words.\n\nExample of wildcard one:\n\n```{go}\n_, err := m.Subscribe(\"foo.*.baz\", func(s string) {\n    // will receive s = \"hello world\"\n})\n_, err := m.Subscribe(\"foo.*\", func(s string) {\n    // will not be called\n})\n\nerr := m.Publish(\"foo.bar\", \"hello world\")\n```\n\nExample of wildcard some:\n\n```{go}\n_, err := m.Subscribe(\"foo.#\", func(s string) {\n    // will receive s = \"hello my world\"\n})\n_, err := m.Subscribe(\"#\", func(s string) {\n    // will receive s = \"hello my world\"\n})\n})\n_, err := m.Subscribe(\"foo.bar.baz.#\", func(s string) {\n    // will receive s = \"hello my world\"\n})\n\nerr := m.Publish(\"foo.bar.baz\", \"hello my world\")\n```\n\nMore concrete example of RabbitMQ could be found at [RabbitMQ tutorial - Topics](https://www.rabbitmq.com/tutorials/tutorial-five-go.html). The topic matching github.com/nqd/mq/matcher implement trie topic routing, inherited much from [fast-topic-matching](https://github.com/tylertreat/fast-topic-matching).\n\n## Benchmark\n\nThis is the result running in an Ubuntu 16.04 64bit, i7-5600U CPU @ 2.60GHz × 4.\n\nSubscribe all 1000 topics:\n\n```{bash}\nBenchmarkMQSubscribe-4              2000            693580 ns/op          144124 B/op       4001 allocs/op\n```\n\nPublish all 100000 messages to a MQ with 1000 subscribers\n\n```{bash}\nBenchmarkMQPublish-4                   3         453835682 ns/op        104704792 B/op   1442775 allocs/op\n```\n\n## See also\n\n- [fast-topic-matching](https://github.com/tylertreat/fast-topic-matching)\n- [qlobber](https://github.com/davedoesdev/qlobber)\n- Very fast and scalable topic routing [1](https://www.rabbitmq.com/blog/2010/09/14/very-fast-and-scalable-topic-routing-part-1/), [2](https://www.rabbitmq.com/blog/2011/03/28/very-fast-and-scalable-topic-routing-part-2/)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnqd%2Fmq","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnqd%2Fmq","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnqd%2Fmq/lists"}