marius / workerd Goto Github PK
View Code? Open in Web Editor NEWA simple background worker for ruby on rails
License: MIT License
A simple background worker for ruby on rails
License: MIT License
Workerd ======= Workerd is a Ruby on Rails plugin which helps running tasks in the background. It is inspired by Bart ten Brinke's worker_queue. Installation ============ cd your_rails_app rails plugin install git://github.com/marius/workerd.git rails generate workerd_migration rake db:migrate Example ======= Create a background job: Workerd::Workpiece.create(:class_name => 'Model', :method_name => 'method') This new job will get picked up by a worker and he will execute Model.method with no arguments. You can add arguments with the :method_arguments option, e.g. :method_arguments => [17, 'foo', Time.now] or :method_arguments => [[42, :symbol]] or :method_arguments => [1]. The method_arguments array will be converted into the actual method arguments with the splat operator, so it has to be an array. Run one worker in foreground during development: rake workerd:run Start one worker in background: rake workerd:start Stop it: rake workerd:stop Customization ============= You can easily create your own jobs with advanced features by inheriting from Workerd::Workpiece and adding a `type` column. For example you can then define a column `progress` as an integer in your database. After this you can use it from your foreground and background code: # in a normal rails request job = MyJob.create(:class_name => 'Foo', :method_name => 'bar') # in an AJAX request render :text => job.progress # in Foo.bar Workerd.current_workpiece.progess = 77 Workerd.current_workpiece.save! Todo ==== * Add pidfile management to support more than one worker * Convert to gem Copyright (c) 2010 Marius Nuennerich, released under the MIT license
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.