{"id":22898268,"url":"https://github.com/lisprez/srq","last_synced_at":"2025-04-01T01:51:41.533Z","repository":{"id":144519625,"uuid":"119937197","full_name":"Lisprez/srq","owner":"Lisprez","description":"It is a Simple and Stupid Message Queue based on Redis","archived":false,"fork":false,"pushed_at":"2018-02-02T07:58:59.000Z","size":6,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-07T02:46:36.065Z","etag":null,"topics":["go-queue","golang","message-queue","redis-queue"],"latest_commit_sha":null,"homepage":null,"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/Lisprez.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":"2018-02-02T05:37:43.000Z","updated_at":"2024-06-22T02:21:01.000Z","dependencies_parsed_at":"2023-07-14T01:45:56.915Z","dependency_job_id":null,"html_url":"https://github.com/Lisprez/srq","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/Lisprez%2Fsrq","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lisprez%2Fsrq/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lisprez%2Fsrq/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lisprez%2Fsrq/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Lisprez","download_url":"https://codeload.github.com/Lisprez/srq/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246569007,"owners_count":20798341,"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":["go-queue","golang","message-queue","redis-queue"],"created_at":"2024-12-14T00:30:18.739Z","updated_at":"2025-04-01T01:51:41.515Z","avatar_url":"https://github.com/Lisprez.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SRQ \u003e\u003e= Stupid Redis message Queue\n\nIt is a so stupid message queue based on redis that I think it is ***Simple***\n\n## Install\n\n```\ngo get -u -v github.com/Lispre/srq\n```\n\n## Feature\n\n1. It supports multi producer push message at the same time, and the same message enqueue *Only* once.\n2. It supports multi consumer fetch message from queue at the same time, and it make sure that every consumer get the different message every time from each other.\n3. It supports the priority configuration of message with **waitWeight** parameter\n\n## API\n\n1. Create a redis connection\n```\nfunc NewConnection(network string // tcp, udp ...\n                   address string // \"127.0.0.1:6379\n                   options options ...redis.DialOption) (redis.Conn, error)\n```\n2. Create a queue\n```\nfunc NewQueue(queueName string, conn redis.Conn) *Queue\n```\n3. Push message to queue\n```\nfunc (queue *Queue) Push(message string, waitWeight int64 // This parameter set more large will wait longer time to consumered by consumer) (bool, error)\n```\n4. Pop message from queue\n```\nfunc (queue *Queue) Pop() (string, error)\n```\n## Example\n\n### producer\n\n```\npackage main\n\nimport (\n\t\"fmt\"\n\t\"github.com/Lispre/srq\"\n)\n\nfunc main() {\n\tconn, err := srq.NewConnection(\"tcp\", \"127.0.0.1:6379\")\n\tif err != nil {\n\t\tfmt.Printf(\"connect redis error\\n\")\n\t\treturn\n\t}\n\tdefer conn.Close()\n\tqueue := srq.NewQueue(\"test_queue\", conn)\n\n\tstatus, err := queue.Push(\"message1\", 11)\n\tif err != nil {\n\t\tfmt.Printf(\"push message error\\n\")\n\t}\n\tif status {\n\t\tfmt.Printf(\"push message success\\n\")\n\t}\n\n\tstatus, err = queue.Push(\"message2\", 22)\n\tif err != nil {\n\t\tfmt.Printf(\"push message error\\n\")\n\t}\n\tif status {\n\t\tfmt.Printf(\"push message success\\n\")\n\t}\n\n\tstatus, err = queue.Push(\"message3\", 33)\n\tif err != nil {\n\t\tfmt.Printf(\"push message error\\n\")\n\t}\n\tif status {\n\t\tfmt.Printf(\"push message success\\n\")\n\t}\n}\n```\n\n### consumer\n\n```\npackage main\n\nimport (\n    \"fmt\"\n    \"github.com/Lispre/srq\"\n)\n\nfunc main() {\n    conn, err := srq.NewConnection(\"tcp\", \"127.0.0.1:6379\")\n    if err != nil {\n        fmt.Printf(\"connect redis error\\n\")\n        return\n    }\n    defer conn.Close()\n    \n    queue := srq.NewQueue(\"test_queue\", conn)\n    \n    msg1, err := queue.Pop()\n    if err != nil {\n        fmt.Printf(\"received message error\\n\")\n    }\n    if msg1 == \"\" {\n        fmt.Printf(\"No message in queue\\n\")\n        return\n    }\n    fmt.Printf(\"message is: %v\\n\", msg1)\n    \n    msg2, err := queue.Pop()\n    if err != nil {\n        fmt.Printf(\"received message error\\n\")\n    }\n    if msg1 == \"\" {\n        fmt.Printf(\"No message in queue\")\n    }\n    fmt.Printf(\"message is: %v\\n\", msg2)\n    \n    msg3, err := queue.Pop()\n    if err != nil {\n        fmt.Printf(\"received message error\\n\")\n    }\n    if msg1 == \"\" {\n        fmt.Printf(\"No message in queue\")\n    }\n    fmt.Printf(\"message is: %v\\n\", msg3)\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flisprez%2Fsrq","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flisprez%2Fsrq","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flisprez%2Fsrq/lists"}