{"id":13878222,"url":"https://github.com/nejdetkadir/safe_poller","last_synced_at":"2025-07-22T04:04:38.606Z","repository":{"id":153495326,"uuid":"629570516","full_name":"nejdetkadir/safe_poller","owner":"nejdetkadir","description":"SafePoller is a Ruby gem that provides a safe and reliable way to perform periodic polling operations in multi-threaded environments","archived":false,"fork":false,"pushed_at":"2023-04-18T17:30:12.000Z","size":12,"stargazers_count":10,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-11T03:22:08.778Z","etag":null,"topics":["poll","polling","ruby","thread"],"latest_commit_sha":null,"homepage":"","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/nejdetkadir.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2023-04-18T15:20:09.000Z","updated_at":"2025-01-21T14:59:05.000Z","dependencies_parsed_at":"2023-04-20T00:08:05.149Z","dependency_job_id":null,"html_url":"https://github.com/nejdetkadir/safe_poller","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/nejdetkadir/safe_poller","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nejdetkadir%2Fsafe_poller","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nejdetkadir%2Fsafe_poller/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nejdetkadir%2Fsafe_poller/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nejdetkadir%2Fsafe_poller/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nejdetkadir","download_url":"https://codeload.github.com/nejdetkadir/safe_poller/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nejdetkadir%2Fsafe_poller/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266424023,"owners_count":23926124,"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","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["poll","polling","ruby","thread"],"created_at":"2024-08-06T08:01:43.166Z","updated_at":"2025-07-22T04:04:38.578Z","avatar_url":"https://github.com/nejdetkadir.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"[![Gem Version](https://badge.fury.io/rb/safe_poller.svg)](https://badge.fury.io/rb/safe_poller)\n![test](https://github.com/nejdetkadir/safe_poller/actions/workflows/test.yml/badge.svg?branch=main)\n![rubocop](https://github.com/nejdetkadir/safe_poller/actions/workflows/rubocop.yml/badge.svg?branch=main)\n[![Ruby Style Guide](https://img.shields.io/badge/code_style-rubocop-brightgreen.svg)](https://github.com/rubocop/rubocop)\n![Ruby Version](https://img.shields.io/badge/ruby_version-\u003e=_2.7.0-blue.svg)\n\n# Safe Poller\n\nSafePoller is a Ruby gem that provides a safe and reliable way to perform periodic polling operations in multi-threaded environments. It offers a simple and intuitive API for running a block of code at a defined interval, while ensuring thread safety and preventing potential race conditions. SafePoller allows developers to focus on implementing their logic without worrying about thread safety issues.\n\n\n## Installation\n\nInstall the gem and add to the application's Gemfile by executing:\n```bash\n$ bundle add safe_poller\n```\n\nOr add the following line to the application's Gemfile:\n```ruby\ngem 'safe_poller', github: 'nejdetkadir/safe_poller', branch: 'main'\n```\n\nIf bundler is not being used to manage dependencies, install the gem by executing:\n```bash\ngem install safe_poller\n```\n\n\n## Usage\n\nTo use SafePoller, simply call the `SafePoller.poll` method, passing in a block of code to be executed at the specified interval:\n```ruby\npoller = SafePoller.poll(interval: 2.0) do\n  # Code to be executed at 2-second intervals\nend\n```\n\nBy default, the interval is set to 1 second. You can also specify the duration of the poll by using the `SafePoller.poll_for` method:\n```ruby\npoller = SafePoller.poll_for(30, interval: 2.0) do\n  # Code to be executed every 2 seconds for 30 seconds\nend\n```\n\nOr, you can specify the end time of the poll using the `SafePoller.poll_until` method:\n```ruby\nend_time = Time.now + 60\npoller = SafePoller.poll_until(end_time, interval: 2.0) do\n  # Code to be executed every 2 seconds until 1 minute from now\nend\n```\n\nYou can pause and resume the poller using the `pause` and `resume` methods, respectively:\n```ruby\npoller.pause # Pauses the poller\npoller.resume # Resumes the poller\n```\n\nYou can check if the poller is currently running or paused using the `running?` and `paused?` methods, respectively:\n```ruby\npoller.running? # Returns true if the poller is running, false otherwise\npoller.paused? # Returns true if the poller is paused, false otherwise\n```\n\nYou can stop the poller using the `stop` method:\n```ruby\npoller.stop # Stops the poller\n```\n\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/nejdetkadir/safe_poller. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/nejdetkadir/safe_poller/blob/main/CODE_OF_CONDUCT.md).\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](LICENSE).\n\n## Code of Conduct\n\nEveryone interacting in the SafePoller project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/nejdetkadir/safe_poller/blob/main/CODE_OF_CONDUCT.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnejdetkadir%2Fsafe_poller","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnejdetkadir%2Fsafe_poller","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnejdetkadir%2Fsafe_poller/lists"}