No description, website, or topics provided.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
commands
examples
model
services
views
.env
.gitignore
.rbenv-gemsets
.ruby-version
Gemfile
Gemfile.lock
IntegrationTest.rb
Procfile
README.md
app.rb
clock.rb
jobs.rb

README.md

typhoon

This is based on part of the Maneuverable Web Architecture at QCon London by Michael Nygaard.

There are three parts to it:

'at' service

Calls the specified url at a given point in time. I have used the chronic gem to parse the date, so it can make sense of pretty much anything...

curl -X POST -d @test_at_call.json http://localhost:4567/at

example:

{
  "at": "now",
  "url": "http://localhost:4567/script/534669f6ba8d2c8c91000001/run"
}

The URL and the time to call it are stored in a database, and I use beanstalk and clockwise to call the url when the time comes.

script factory

Builds a script to do a specified task, stores it in a key/value store (using moneta), and returns a url for the script.

curl -X POST -d @test_factory_call.json http://localhost:4567/script/factory

example request:

{
  "action": "send_email",
  "data": {
    "to": "abraithw@gmail.com",
    "subject": "Hello",
    "name": "Andrew"
  }
}

script engine

Runs the scripts built by the factory

to run script :id

curl http://localhost:4567/script/:id/run

to run an abritrary script

curl -X POST -d @test_script.json http://localhost:4567/script/run

example script:

{
    "one": {
        "command": "erb",
        "data": {
            "template": "email",
            "template_data": {
                "name": "Andrew"
            }
        }
    },
    "two": {
        "command": "email",
        "data": {
            "to": "abraithw@gmail.com",
          	"subject": "test email"
        }
    }
}

Creating the database

from the project's root directory:

typingincolor:typhoon andrew$ irb
irb(main):001:0> require './model/Task.rb'
=> true
irb(main):002:0> DataMapper.auto_migrate!
=> DataMapper
irb(main):003:0> quit

Running everything...

You will need beanstalk (brew install beanstalk), and foreman

> beanstalkd &
> foreman start

To run the integration tests

> ruby IntegrationTest.rb