davidkellis / colony Goto Github PK
View Code? Open in Web Editor NEWA simple distributed task library in Ruby.
A simple distributed task library in Ruby.
Colony is a small distributed task library. Depends on: beanstalkd: http://kr.github.com/beanstalkd/ redis: http://code.google.com/p/redis/ Getting started: 1. Install dependencies. This is how I did it: beanstalkd: sudo port install beanstalkd beanstalk-client gem: gem install beanstalk-client redis: sudo port install redis redis gem: gem install redis leiri gem: git clone git://github.com/davidkellis/leiriparser.git cd leiriparser ./install.sh uuidtools gem: gem install uuidtools 2. Clone colony: git clone git://github.com/davidkellis/colony.git 3. Try out the example in the /example directory. First run redis and beanstalkd. Then run example/worker.rb, followed by example/simple.rb. 4. Try writing your own example task similar to what is in simple.rb and worker.rb. First run redis and beanstalkd. Client side: require 'colony' # Create Colony client object. # First param is the set of beanstalkd servers # Second param is the "global" redis server (The redis server that all clients/workers use to access job and task info) c = Colony::Client.new(['localhost:11300'], {host: 'localhost'}) # Create a task to multiply the numbers 4, 5, and 6 (i.e. 4 * 5 * 6) result = c.task(:multiply, [4, 5, 6]) # Wait for the task to complete. This call to value() will wait indefinitely for the result to be made available. # This will block, while polling for the for the task's result. # Once the task result is made available (i.e. once the worker completes the task, saves the result, and updates the # task with the result URI), the client will go download the result and return it. puts result.value Worker side: require 'colony' def multiply(*args) args.reduce(:*) end # Create Colony worker object. # First param is the set of beanstalkd servers # Second param is the "global" redis server (The redis server that all clients/workers use to access job and task info) # Third param is the "local" redis server (The redis server that the worker stores its task results to) w = Colony::Worker.new(['localhost:11300'], {host: 'localhost'}, {host: 'localhost'}) # Start the server. This will cause the server to wait for tasks to be added to the work queue. w.start Licensed under the MIT license: Copyright (c) 2010 David K. Ellis Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
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.