The New JSON BUS REST API
Read: Bifrost/DevEnvironmentHowto
In a breif git clone git checkout next # get BUS's code git submodule init git submodule update scripts/links_bus.sh
bundle # needs vpn
install CouchDB
- Homebrew client:
lib/divan.rb
RackProc#store_job
RackBackupJob
RestoreObject
BackupJob
- But
RackDownloader
,RackDoc
,RackRestoreJob
don't use DivanBackupGroup
,backup_sites
(RestoreObject)
create databases in CouchDB backup-groups backup-sites backup-jobs managed_jobs
install Redis (API Keys management, IP whitelist, rate limit, job queue, shavlik config)
Start Service Foreman is a manager for Procfile-based applications. bundle exec foreman start
RabbitMQ (AMPQ)
- bunny
- lib/rabbitmq.rb
- Dispatcher
- RackProc
-
Rack::CommonLogger
-
Rack::JSONP Handle JSONP calls
-
Perimeter A filter, sanitizes headers & body; plus some routes (special cases)
-
Rack::Session::Pool
-
Warden Authentication (
bus_basic
- username & password) -
Authenticate checks
API_KEY
(header). API keys are stored in redis, with its metadata. -
IpWhitelist checks IP against the whitelist, which is one of the API key's metadata.
-
Router API URL pattern:
:api/:resource/:id/:section/:section_id
(defined in UriMapper) -
ApiStats doing nothing now. Supposed to do stats.
-
Rack::PostBodyToParams
-
Authorize checks if the caller is authorized to make the API call (in the right scope,
api_scope_delegate
). E.g. looking for a user, who has to be descended from thecurrent_partner
. SeeModelMixin
and delegators (api/delegates
). -
Dispatcher calls the
:endpoint
in the API definition. if there is any event defined in the API definition, all events will be published (to RabbitMQ). available endpoints (lib/rackable_model
)RackModel
AnRackable
object. Dispatches API actions (seeModelMixin
) to models. (Expose models to the web).RackProc
Queue Jobs.- use
model.message_delegate
to generate message. (ModelMixin
) - use Redis for concurrency check
- put Job data in CouchDB
- queue in RabbitMQ
- use
RackDoc
CRUD documents (in CounchDB)RackPing
only respond to HEAD and return nothing butheader["X-Ping-Response"] = "Pong"
RackBackupJob
read / manage backup jobs. uses CouchDB as storage, and redis as job queue / tracker.RackRestoreJob
managed job API. uses CouchDB as storage, and redis job queue.RackDownloader
initiate, request assets (VMDK's) downloads. Nginx does real download job.ApiDocumentationRack
generates API docs (/help)RackProxy
not implemented yet END
-
create an application object
-
use Ruby instead of YAML for API definitions
-
use debugger instead of ruby-debug19
-
use :group in Gemfile (which means introduce "mode")
-
too many constants, which means too many global states.
-
while there is a logger object, it still uses "puts" a lot.
-
code is kinda messy. (perimeter.rb is a good example)
-
in
RackProc
, duplicated message in CouchDB & RabbitMQ ?
?
- why there is a gems folder?