Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ost-scheduler

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ost-scheduler

  • 0.1.1
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Ost Scheduler

Ost-Scheduler is an extension to Ost that adds support for queueing items in the future.

Description

Ost provides simple, lightweight background job functionality.

Ost-Scheduler makes it easy to enqueue object ids and process them with workers.

Say you want to process video uploads. In your application you will have something like this:

Ost[:videos_to_process].push_at( Time.now + 60 , @video.id )

Then, you will have a worker that will look like this:

require "ost-scheduler"

Ost[:videos_to_process].each_delayed do |id|
  # Do something with it!
end

Usage

Ost uses a lightweight Redis client called [Redic][redic]. To connect to a Redis database, you will need to set an instance of Redic, with a URL of the form redis://:<passwd>@<host>:<port>/<db>.

You can customize the connection by calling Ost.redis=:

require "ost-scheduler"

Ost.redis = Redic.new("redis://127.0.0.1:6379")

Then you only need to refer to a queue for it to pop into existence:

require "ost-scheduler"

Ost.redis = Redic.new("redis://127.0.0.1:6379")

Ost[:event].push_at(@datetime, @feed.id)

Ost defaults to a Redic connection to redis://127.0.0.1:6379. The example above could be rewritten as:

require "ost-scheduler"

Ost[:event].push_at(@datetime, @feed.id)

A worker is a Ruby file with this basic code:

require "ost-scheduler"

Ost[:rss_feeds].each_delayed do |id|
  # ...
end

Available methods

Ost[:example].push_at(datetime, item): add item to the :example queue in a exactly datetime.

Ost[:example].each_delayed { |item| ... }: consume item from the :example queue. .

Ost.stop: halt processing for all queues.

Ost[:example].stop: halt processing for the example queue.

Installation

$ gem install ost-scheduler

FAQs

Package last updated on 24 Mar 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc