{"id":13817731,"url":"https://github.com/EverythingMe/go-disque","last_synced_at":"2025-05-15T20:32:46.083Z","repository":{"id":31195698,"uuid":"34756430","full_name":"EverythingMe/go-disque","owner":"EverythingMe","description":"Go client for Disque","archived":false,"fork":false,"pushed_at":"2018-01-10T11:08:19.000Z","size":42,"stargazers_count":134,"open_issues_count":4,"forks_count":17,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-23T21:32:50.329Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/EverythingMe.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":"2015-04-28T21:18:37.000Z","updated_at":"2025-03-04T10:43:15.000Z","dependencies_parsed_at":"2022-08-24T14:21:28.759Z","dependency_job_id":null,"html_url":"https://github.com/EverythingMe/go-disque","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/EverythingMe%2Fgo-disque","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EverythingMe%2Fgo-disque/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EverythingMe%2Fgo-disque/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EverythingMe%2Fgo-disque/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/EverythingMe","download_url":"https://codeload.github.com/EverythingMe/go-disque/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254418738,"owners_count":22068142,"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":[],"created_at":"2024-08-04T06:00:54.340Z","updated_at":"2025-05-15T20:32:43.655Z","avatar_url":"https://github.com/EverythingMe.png","language":"Go","funding_links":[],"categories":["Misc"],"sub_categories":[],"readme":"# go-disque\n\nA simple Go client for the Disque in-memory distributed queue https://github.com/antirez/disque\n\n## Example:\n\n```go\n\nimport (\n\t\"fmt\"\n\t\"time\"\n\t\n\t\"github.com/garyburd/redigo/redis\"\n\t\"github.com/EverythingMe/go-disque/disque\"\n)\n\nfunc dial(addr string) (redis.Conn, error) {\n\treturn redis.Dial(\"tcp\", addr)\n}\n\nfunc ExampleClient() {\n\n\tpool := disque.NewPool(disque.DialFunc(dial), \"127.0.0.1:7711\", \"127.0.0.1:7712\")\n\n\tclient, err := pool.Get()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\t\n\t\n\tdefer client.Close()\n\n\tqname := \"test1\"\n\n\t// Create an \"add\" request with optional parameters.\n\t// TODO: create a builder-style API for this\n\tja := disque.AddRequest{\n\t\tJob: disque.Job{\n\t\t\tQueue: qname,\n\t\t\tData:  []byte(\"foo\"),\n\t\t},\n\t\tTimeout: time.Millisecond * 100,\n\t}\n\n\t// Add the job to the queue\n\tif _, err := client.Add(ja); err != nil {\n\t\tpanic(err)\n\t}\n\n\tjob, err := client.Get(time.Second, qname)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(string(job.Data))\n\t// Output:\n\t// foo\n}\n\n```\n\n\n# Tasque\n## Disque based remote task execution queue for Go\n\nTaskque levereges Disque (https://github.com/antirez/disque) to create a simple and easy to use\ndistributed task execution queue.\n\nThe idea is simple - you creat TaskHandlers - callbacks that receive Tasks - which are simple execution\ncontext objects. Then you run a Worker process that can handle multiple TaskHandlers by name. You can then \nenqueue tasks for the handlers from any machine in your cluster using a Client, and they get executed.\n\n## Example - Creating a Worker\n\n\n```go\n\nimport (\n\t\"github.com/EverythingMe/go-disque/tasque\"\n\t\n\t\"crypto/md5\"\n\t\"fmt\"\n\t\"io\"\n\t\"net/http\"\n\t\"os\"\n\t\"time\"\n)\n\n// Step 1: Define a handler that has a unique name\nvar Downloader = tasque.FuncHandler(func(t *tasque.Task) error {\n\n\tu := t.Params[\"url\"].(string)\n\tres, err := http.Get(u)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer res.Body.Close()\n\n\tfp, err := os.Create(fmt.Sprintf(\"/tmp/%x\", md5.Sum([]byte(u))))\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer fp.Close()\n\n\tif _, err := io.Copy(fp, res.Body); err != nil {\n\t\treturn err\n\t}\n\tfmt.Printf(\"Downloaded %s successfully\\n\", u)\n\n\treturn nil\n\t\n}, \"download\")\n\n\n\n// Step 2: Registering the handler and starting a Worker\n\nfunc main() {\n\t\n\t// Worker with 10 concurrent goroutines. In real life scenarios set this to much higher values...\n\tworker := tasque.NewWorker(10, \"127.0.0.1:7711\")\n\n\t// register our downloader\n\tworker.Handle(Downloader)\n\t\n\t// Run the worker\n\tworker.Run()\n\n}\n\n\n```\n\n\n\n# Example - Enqueuing a task\n\n```go\n\nfunc main() {\n\t\n\tclient := tasque.NewClient(5*time.Second, \"127.0.0.1:7711\")\n\n\ttask := tasque.NewTask(Downloader.Id()).Set(\"url\", \"http://google.com\")\n\terr := client.Do(task)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FEverythingMe%2Fgo-disque","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FEverythingMe%2Fgo-disque","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FEverythingMe%2Fgo-disque/lists"}