{"id":25404863,"url":"https://github.com/asim/mq","last_synced_at":"2026-01-12T06:35:45.539Z","repository":{"id":28233281,"uuid":"31738008","full_name":"asim/mq","owner":"asim","description":"An in-memory message broker","archived":false,"fork":false,"pushed_at":"2025-01-30T21:16:12.000Z","size":113,"stargazers_count":172,"open_issues_count":0,"forks_count":37,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-05-16T14:03:51.089Z","etag":null,"topics":["broker","golang","message-broker"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/asim.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":"2015-03-05T21:38:43.000Z","updated_at":"2025-04-29T06:34:43.000Z","dependencies_parsed_at":"2024-05-31T06:38:53.521Z","dependency_job_id":"3f6f14f5-7145-41ab-a916-d713a01acfda","html_url":"https://github.com/asim/mq","commit_stats":null,"previous_names":["asim/emque","asim/mq"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asim%2Fmq","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asim%2Fmq/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asim%2Fmq/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asim%2Fmq/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/asim","download_url":"https://codeload.github.com/asim/mq/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254544146,"owners_count":22088807,"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":["broker","golang","message-broker"],"created_at":"2025-02-16T04:11:50.939Z","updated_at":"2026-01-12T06:35:45.533Z","avatar_url":"https://github.com/asim.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MQ [![License](https://img.shields.io/:license-apache-blue.svg)](https://opensource.org/licenses/Apache-2.0) [![Go Report Card](https://goreportcard.com/badge/asim/mq)](https://goreportcard.com/report/github.com/asim/mq)\n\nMQ is an in-memory message broker\n\n## Features\n\n- In-memory message broker\n- HTTP or gRPC transport\n- Clustering\n- Sharding\n- Proxying\n- Discovery\n- Auto retries\n- TLS support\n- Command line interface\n- Interactive prompt\n- Go client library\n\nEmque generates a self signed certificate by default if no TLS config is specified\n\n## API\n\nPublish\n```\n/pub?topic=string\tpublish payload as body\n```\n\nSubscribe\n```\n/sub?topic=string\tsubscribe as websocket\n```\n\n## Architecture\n\n- Emque servers are standalone servers with in-memory queues and provide a HTTP API\n- Emque clients shard or cluster Emque servers by publish/subscribing to one or all servers\n- Emque proxies use the go client to cluster Emque servers and provide a unified HTTP API\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"mq.png\" /\u003e\n\u003c/p\u003e\n\nBecause of this simplistic architecture, proxies and servers can be chained to build message pipelines\n\n## Usage\n\n### Install\n\n```shell\ngo get github.com/asim/mq\n```\n\n### Run Server\n\nListens on `*:8081`\n```shell\nmq\n```\n\nSet server address\n```shell\nmq --address=localhost:9091\n```\n\nEnable TLS\n```shell\nmq --cert_file=cert.pem --key_file=key.pem\n```\n\nPersist to file per topic\n```shell\nmq --persist\n```\n\nUse gRPC transport\n```shell\nmq --transport=grpc\n```\n\n### Run Proxy\n\nEmque can be run as a proxy which includes clustering, sharding and auto retry features.\n\nClustering: Publish and subscribe to all Emque servers\n\n```shell\nmq --proxy --servers=10.0.0.1:8081,10.0.0.1:8082,10.0.0.1:8083\n```\n\nSharding: Requests are sent to a single server based on topic\n\n```shell\nmq --proxy --servers=10.0.0.1:8081,10.0.0.1:8082,10.0.0.1:8083 --select=shard\n```\n\nResolver: Use a name resolver rather than specifying server ips\n\n```shell\nmq --proxy --resolver=dns --servers=mq.proxy.dev\n```\n\n### Run Client\n\nPublish\n\n```shell\necho \"A completely arbitrary message\" | mq --client --topic=foo --publish --servers=localhost:8081\n```\n\nSubscribe\n\n```shell\nmq --client --topic=foo --subscribe --servers=localhost:8081\n``` \n\nInteractive mode\n```shell\nmq -i --topic=foo\n```\n\n### Publish\n\nPublish via HTTP\n\n```\ncurl -k -d \"A completely arbitrary message\" \"https://localhost:8081/pub?topic=foo\"\n```\n\n### Subscribe\n\nSubscribe via websockets\n\n```\ncurl -k -i -N -H \"Connection: Upgrade\" \\\n\t-H \"Upgrade: websocket\" \\\n\t-H \"Host: localhost:8081\" \\\n\t-H \"Origin:http://localhost:8081\" \\\n\t-H \"Sec-Websocket-Version: 13\" \\\n\t-H \"Sec-Websocket-Key: Emque\" \\\n\t\"https://localhost:8081/sub?topic=foo\"\n```\n\n## Go Client [![GoDoc](https://godoc.org/github.com/asim/mq/client?status.svg)](https://godoc.org/github.com/asim/mq/client)\n\nEmque provides a simple go client\n\n```go\nimport \"github.com/asim/mq/client\"\n```\n\n### Publish\n\n```go\n// publish to topic foo\nerr := client.Publish(\"foo\", []byte(`bar`))\n```\n\n### Subscribe\n\n```go\n// subscribe to topic foo\nch, err := client.Subscribe(\"foo\")\nif err != nil {\n\treturn\n}\n\ndata := \u003c-ch\n```\n\n### New Client\n\n```go\n// defaults to Emque server localhost:8081\nc := client.New()\n```\n\ngRPC client\n\n```go\nimport \"github.com/asim/mq/client/grpc\"\n\nc := grpc.New()\n```\n\n### Clustering\n\nClustering is supported on the client side. Publish/Subscribe operations are performed against all servers.\n\n```go\nc := client.New(\n\tclient.WithServers(\"10.0.0.1:8081\", \"10.0.0.1:8082\", \"10.0.0.1:8083\"),\n)\n```\n\n### Sharding\n\nSharding is supported via client much like gomemcache. Publish/Subscribe operations are performed against a single server.\n\n```go\nimport \"github.com/asim/mq/client/selector\"\n\nc := client.New(\n\tclient.WithServers(\"10.0.0.1:8081\", \"10.0.0.1:8082\", \"10.0.0.1:8083\"),\n\tclient.WithSelector(new(selector.Shard)),\n)\n```\n### Resolver\n\nA name resolver can be used to discover the ip addresses of Emque servers\n\n```go\nimport \"github.com/asim/mq/client/resolver\"\n\nc := client.New(\n\t// use the DNS resolver\n\tclient.WithResolver(new(resolver.DNS)),\n\t// specify DNS name as server\n\tclient.WithServers(\"mq.proxy.local\"),\n)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasim%2Fmq","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fasim%2Fmq","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasim%2Fmq/lists"}