{"id":18026809,"url":"https://github.com/yegor256/always","last_synced_at":"2026-01-04T23:02:45.296Z","repository":{"id":242061162,"uuid":"808572336","full_name":"yegor256/always","owner":"yegor256","description":"A simple Ruby framework that spins a loop forever, in a background thread","archived":false,"fork":false,"pushed_at":"2024-09-16T13:36:41.000Z","size":71,"stargazers_count":2,"open_issues_count":2,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-09-17T13:03:17.825Z","etag":null,"topics":["concurrency","ruby","ruby-gem","thread","threading"],"latest_commit_sha":null,"homepage":"https://rubygems.org/gems/always","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/yegor256.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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":"2024-05-31T10:51:00.000Z","updated_at":"2024-09-16T13:36:13.000Z","dependencies_parsed_at":"2024-06-11T20:08:51.800Z","dependency_job_id":"7874c0c0-dd58-4621-a12f-3834021d1c72","html_url":"https://github.com/yegor256/always","commit_stats":null,"previous_names":["yegor256/always"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yegor256%2Falways","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yegor256%2Falways/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yegor256%2Falways/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yegor256%2Falways/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yegor256","download_url":"https://codeload.github.com/yegor256/always/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245764713,"owners_count":20668466,"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","ruby","ruby-gem","thread","threading"],"created_at":"2024-10-30T08:08:07.733Z","updated_at":"2026-01-04T23:02:45.284Z","avatar_url":"https://github.com/yegor256.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Runs a Background Loop Forever\n\n[![DevOps By Rultor.com](https://www.rultor.com/b/yegor256/always)](https://www.rultor.com/p/yegor256/always)\n[![We recommend RubyMine](https://www.elegantobjects.org/rubymine.svg)](https://www.jetbrains.com/ruby/)\n\n[![rake](https://github.com/yegor256/always/actions/workflows/rake.yml/badge.svg)](https://github.com/yegor256/always/actions/workflows/rake.yml)\n[![PDD status](https://www.0pdd.com/svg?name=yegor256/always)](https://www.0pdd.com/p?name=yegor256/always)\n[![Gem Version](https://badge.fury.io/rb/always.svg)](https://badge.fury.io/rb/always)\n[![Test Coverage](https://img.shields.io/codecov/c/github/yegor256/always.svg)](https://codecov.io/github/yegor256/always?branch=master)\n[![Yard Docs](https://img.shields.io/badge/yard-docs-blue.svg)](https://rubydoc.info/github/yegor256/always/master/frames)\n[![Hits-of-Code](https://hitsofcode.com/github/yegor256/always)](https://hitsofcode.com/view/github/yegor256/always)\n[![License](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/yegor256/always/blob/master/LICENSE.txt)\n\nThis simple Ruby gem helps you run a loop forever, in a background thread.\n\n```ruby\nrequire 'always'\n# Prepare, with five threads and a block:\na = Always.new(5) do\n  puts \"I'm alive\"\nend\n# Start them all together spinning forever with 30-seconds delay between cycles:\na.start!(30)\n# Stop them all together:\na.stop!\n```\n\nYou may be interested to get the backtraces of the exceptions that\nhappened most recently:\n\n```ruby\n# Keep the last 10 error backtraces in memory:\na = Always.new(5, max_backtraces: 10)\n# Set an error handler:\na.on_error do |exception, thread_id|\n  puts \"Error in thread #{thread_id}: #{exception.message}\"\nend\n# Start them:\na.start!\n# Retrieve the backtraces:\np a.backtraces\n```\n\nThat's it.\n\n## How to contribute\n\nRead\n[these guidelines](https://www.yegor256.com/2014/04/15/github-guidelines.html).\nMake sure your build is green before you contribute\nyour pull request. You will need to have\n[Ruby](https://www.ruby-lang.org/en/) 3.0+ and\n[Bundler](https://bundler.io/) installed. Then:\n\n```bash\nbundle update\nbundle exec rake\n```\n\nIf it's clean and you don't see any error messages, submit your pull request.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyegor256%2Falways","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyegor256%2Falways","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyegor256%2Falways/lists"}