{"id":22843532,"url":"https://github.com/mazingstudio/hop","last_synced_at":"2025-04-28T13:44:04.970Z","repository":{"id":83577942,"uuid":"139479533","full_name":"mazingstudio/hop","owner":"mazingstudio","description":"An AMQP client wrapper that provides easy work queue semantics","archived":false,"fork":false,"pushed_at":"2018-10-18T21:59:56.000Z","size":16,"stargazers_count":22,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"develop","last_synced_at":"2025-03-30T10:11:18.133Z","etag":null,"topics":["amqp","golang","queue","rabbitmq","workqueue"],"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/mazingstudio.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-07-02T18:26:14.000Z","updated_at":"2023-12-03T19:46:06.000Z","dependencies_parsed_at":null,"dependency_job_id":"d5b9cfd4-a43e-439c-bb89-d36e93b5012d","html_url":"https://github.com/mazingstudio/hop","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mazingstudio%2Fhop","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mazingstudio%2Fhop/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mazingstudio%2Fhop/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mazingstudio%2Fhop/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mazingstudio","download_url":"https://codeload.github.com/mazingstudio/hop/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251321525,"owners_count":21570755,"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":["amqp","golang","queue","rabbitmq","workqueue"],"created_at":"2024-12-13T02:15:33.607Z","updated_at":"2025-04-28T13:44:04.948Z","avatar_url":"https://github.com/mazingstudio.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Hop\n\n[![GoDoc](https://godoc.org/github.com/mazingstudio/hop?status.svg)](https://godoc.org/github.com/mazingstudio/hop)\n[![Go Report Card](https://goreportcard.com/badge/github.com/mazingstudio/hop)](https://goreportcard.com/report/github.com/mazingstudio/hop)\n[![license](https://img.shields.io/github/license/mashape/apistatus.svg)]()\n\n_An AMQP client wrapper that provides easy work queue semantics_\n\n## Introduction\n\nHop consists of a simple set of abstractions over AMQP concepts that allow you to think in terms of jobs and topics, rather than queues, exchanges and routing.\n\n### Jobs\n\nThe most basic abstraction in Hop are Jobs, which are work units that may be marked as done or failed by your worker processes. When a Job is completed succesfully, it gets removed from the queue. If a Job fails, on the other hand, the worker has the option of requeueing it or dropping it altogether. If a worker dies in the middle of processing a Job, the Job is placed back into the queue. All of this maps to AMQP messages and `ack` and `reject` mechanics.\n\n### Topics\n\nSimilarly to the beanstalkd concept of tubes, Hop introduces Topics, which are distinct queues into which producers can put work units, and from which workers can pull them for processing. Underneath, a Topic is a mapping to an AMQP TCP channel, and a queue with the same name as the Topic. Note that Topics are _not_ the same as AMQP exchange topics.\n\n### The Work Queue\n\nThe third Hop abstraction is the Work Queue, which is nothing more than the grouping of Topics a worker or producer can interact with. The Work Queue abtracts over the TCP connection to the AMQP broker and performs such tasks as dialing, graceful shutdown, and declaration of new channels. Underneath, it maps to an AMQP direct exchange.\n\n## Usage\n\n```go\npackage main\n\nimport (\n\tlog \"github.com/Sirupsen/logrus\"\n\t\"github.com/mazingstudio/hop\"\n)\n\nfunc main() {\n\t// Initialize a WorkQueue with the default configuration\n\twq, err := hop.DefaultQueue(\"amqp://guest:guest@localhost:5672/\")\n\tif err != nil {\n\t\tlog.Fatalf(\"error creating queue: %s\", err)\n\t}\n\t// Make sure to gracefully shut down\n\tdefer wq.Close()\n\n\t// Get the \"tasks\" Topic handle\n\ttasks, err := wq.GetTopic(\"tasks\")\n\tif err != nil {\n\t\tlog.Fatalf(\"error getting topic: %s\", err)\n\t}\n\n\t// Put a Job into the \"tasks\" Topic\n\terr = tasks.Put([]byte(\"Hello\"))\n\tif err != nil {\n\t\tlog.Fatalf(\"error putting: %s\", err)\n\t}\n\n\t// Pull the Job from the Topic\n\thello, err := tasks.Pull()\n\tif err != nil {\n\t\tlog.Fatalf(\"error pulling: %s\", err)\n\t}\n\t// This should print \"hello\"\n\tlog.Infof(\"job body: %s\", hello.Body())\n\n\t// Mark the Job as failed and requeue\n\thello.Fail(true)\n\n\t// Pull the Job again\n\thello2, err := tasks.Pull()\n\tif err != nil {\n\t\tlog.Fatalf(\"error pulling: %s\", err)\n\t}\n\tlog.Infof(\"job body: %s\", hello.Body())\n\n\t// Mark the Job as done\n\thello2.Done()\n}\n```\n\n## License \u0026 Third Party Code\n\nHop uses [`streadway/amqp`](https://github.com/streadway/amqp) internally.\n\nHop is distributed under the MIT License. Please refer to `LICENSE` for more details.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmazingstudio%2Fhop","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmazingstudio%2Fhop","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmazingstudio%2Fhop/lists"}