{"id":26546872,"url":"https://github.com/changsongl/delay-queue-client","last_synced_at":"2025-03-22T05:28:12.899Z","repository":{"id":57585550,"uuid":"330117206","full_name":"changsongl/delay-queue-client","owner":"changsongl","description":"delay-queue client in Golang. It is the SDK written in Golang for 有赞 delay queue.","archived":false,"fork":false,"pushed_at":"2022-08-29T11:34:39.000Z","size":23,"stargazers_count":1,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-12-18T08:36:13.823Z","etag":null,"topics":["delay-jobs","delay-queue","golang","redis","sdk"],"latest_commit_sha":null,"homepage":"https://github.com/changsongl/delay-queue","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/changsongl.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":"2021-01-16T08:23:48.000Z","updated_at":"2022-04-22T01:54:20.000Z","dependencies_parsed_at":"2022-09-10T15:51:37.350Z","dependency_job_id":null,"html_url":"https://github.com/changsongl/delay-queue-client","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/changsongl%2Fdelay-queue-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/changsongl%2Fdelay-queue-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/changsongl%2Fdelay-queue-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/changsongl%2Fdelay-queue-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/changsongl","download_url":"https://codeload.github.com/changsongl/delay-queue-client/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244912803,"owners_count":20530764,"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":["delay-jobs","delay-queue","golang","redis","sdk"],"created_at":"2025-03-22T05:28:12.360Z","updated_at":"2025-03-22T05:28:12.868Z","avatar_url":"https://github.com/changsongl.png","language":"Go","readme":"# delay-queue-client\ndelay-queue client in Golang. It is the SDK written in Golang for https://github.com/changsongl/delay-queue\n\n### How to use?\n````golang\npackage main\n\nimport (\n\t\"fmt\"\n\t\"github.com/changsongl/delay-queue-client/client\"\n\t\"github.com/changsongl/delay-queue-client/consumer\"\n\t\"github.com/changsongl/delay-queue-client/job\"\n\t\"time\"\n)\n\nfunc main() {\n\t// job object\n\tmyTopic, myID := \"my-topic\", \"my-id\"\n\tj, err := job.New(myTopic, myID, job.DelayOption(2*time.Second), job.TTROption(30*time.Second))\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\t// client\n\tcli := client.NewClient(\"127.0.0.1:8000\")\n\t// adding job to delay queue, if job is exist will be failed\n\tif err = cli.AddJob(j); err != nil {\n\t\tpanic(err)\n\t}\n\n\t// replace the job, even if the job is exists\n\tif err = cli.ReplaceJob(j); err != nil {\n\t\tpanic(err)\n\t}\n\n\t// delete the job\n\tif err = cli.DeleteJob(myTopic, myID); err != nil {\n\t\tpanic(err)\n\t}\n\n\t// pop the job from queue, no recommended. please use consumer.\n\ttopic, id, body, delay, ttr, err := cli.PopJob(myTopic, 3*time.Second)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tfmt.Println(topic, id, body, delay, ttr)\n\n\t// finish the job, after having processed the job\n\tif err = cli.FinishJob(myTopic, myID); err != nil {\n\t\tpanic(err)\n\t}\n\n\t// consumer jobs\n\tc := consumer.New(\n\t\tcli,\n\t\ttopic,\n\t\tconsumer.WorkerNumOption(1),\n\t\tconsumer.PopTimeoutOption(3*time.Second),\n\t)\n\tch := c.Consume()\n\tfor jobMsg := range ch {\n\t\tid := jobMsg.GetID()\n\t\tbody := jobMsg.GetBody()\n\n\t\t// do your job\n\t\tfmt.Println(id, body)\n\n\t\tif id == \"xxx\" {\n\t\t\t// job is not valid anymore\n\t\t\tif err = jobMsg.Finish(); err != nil {\n\t\t\t\t// do something\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\n\t\tif err = jobMsg.Finish(); err != nil {\n\t\t\t// do something\n\t\t}\n\t}\n}\n````\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchangsongl%2Fdelay-queue-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchangsongl%2Fdelay-queue-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchangsongl%2Fdelay-queue-client/lists"}