{"id":22025185,"url":"https://github.com/drexed/active_concurrency","last_synced_at":"2025-03-23T10:46:10.308Z","repository":{"id":59150278,"uuid":"169886949","full_name":"drexed/active_concurrency","owner":"drexed","description":"Gem for developing simple concurrency programs.","archived":false,"fork":false,"pushed_at":"2019-02-13T05:57:05.000Z","size":73,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-03-23T01:23:21.350Z","etag":null,"topics":["concurrency","multiprocessing","multithreading","parallel","ruby"],"latest_commit_sha":null,"homepage":"http://drexed.github.io/active_concurrency","language":"Ruby","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/drexed.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-02-09T16:29:31.000Z","updated_at":"2019-02-13T05:56:42.000Z","dependencies_parsed_at":"2022-09-13T10:50:15.617Z","dependency_job_id":null,"html_url":"https://github.com/drexed/active_concurrency","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drexed%2Factive_concurrency","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drexed%2Factive_concurrency/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drexed%2Factive_concurrency/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drexed%2Factive_concurrency/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/drexed","download_url":"https://codeload.github.com/drexed/active_concurrency/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245090861,"owners_count":20559296,"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":["concurrency","multiprocessing","multithreading","parallel","ruby"],"created_at":"2024-11-30T07:14:52.018Z","updated_at":"2025-03-23T10:46:10.277Z","avatar_url":"https://github.com/drexed.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ActiveConcurrency\n\nActiveConcurrency that makes it easy to work with thread/process\nworkers and pools.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'active_concurrency'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install active_concurrency\n\n## Table of Contents\n\n* [Usage](#usage)\n* [Workers](#worker)\n* [Pools](#pools)\n* [Schedulers](#schedulers)\n\n## Usage\n\nBefore getting started it is best to understand when to use processes vs\nthreads workers/pools.\n\nUse threads when you need to access an outer shared resource or looking to\nrun light weight executors. You may find threads harder to debug for\nunexpected errors.\n\nUse processes when you don't need to access an outer shared resource.\nProcesses are also more memory intensive as the load an its\nown identical system, but have the added benefit of being easier to debug.\nUse the following as a guide when dealing with ActiveRecord:\nhttps://makandracards.com/makandra/556-test-concurrent-ruby-code\n\nPlay around with both until you find the best performance mix of speed and\nmemory usage. Very rarely will you find any benefit of running both together.\nWe suggest you start with threads before using processes.\n\n## Workers\n\nWorkers are a single unit that contain its own queue to and process data in\na FIFO sequence. You can use a worker without a pool if you need to process\na small amount items.\n\n```ruby\nworker = ActiveConcurrency::Processes::Worker.new(name: 'us-east')\n\nworker.schedule { expensive_code }\nworker.schedule { expensive_code }\n...\nworker.shutdown\n```\n\n## Pools\n\nPools are a group of workers that queue data based on a selected scheduling\nalgorithm. Use a pool to process a large amount of items and spread loads\nbetween many workers.\n\n```ruby\npool = ActiveConcurrency::Threads::Pool.new(size: 10)\n\npool.schedule { expensive_code }\npool.schedule { expensive_code }\n...\npool.shutdown\n```\n\n## Schedulers\n\nThere are currently three scheduling algorithms to choose that bring\nflexibility to your pools.\n\n**Least busy (default)**\nThe least busy algorithm will schedule the job in the worker with\nthe smallest sized queue.\n\n```ruby\nActiveConcurrency::Threads::Pool.new(\n  scheduler: ActiveConcurrency::Schedulers::LeastBusy\n)\n```\n\n**Round robin**\nThe round robin algorithm will schedule the job in the next sequentially available worker queue.\n\n```ruby\nActiveConcurrency::Processes::Pool.new(\n  scheduler: ActiveConcurrency::Schedulers::RoundRobin\n)\n```\n\n**Topic**\nThe topic algorithm will schedule the job in the selected topic worker queue.\nThis is similar to background programs or message buses.\n\n```ruby\nActiveConcurrency::Threads::Pool.new(\n  scheduler: ActiveConcurrency::Schedulers::Topic,\n  topics: %w[topic_1 topic_2 topic_3]\n)\n```\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/drexed/active_concurrency. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n\n## Code of Conduct\n\nEveryone interacting in the ActiveConcurrency project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/drexed/active_concurrency/blob/master/CODE_OF_CONDUCT.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrexed%2Factive_concurrency","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdrexed%2Factive_concurrency","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrexed%2Factive_concurrency/lists"}