Permalink
Browse files

(new) initial commit. sorry, buddy, but a 50M git repo just doesn't c…

…ut it
  • Loading branch information...
Sven Fuchs
Sven Fuchs committed Nov 9, 2011
0 parents commit 9d77d5d0e02777bcb53f7beb30dfdfa69383c5f5
Showing 498 changed files with 49,390 additions and 0 deletions.
@@ -0,0 +1 @@
+config/travis.yml
4 .rspec
@@ -0,0 +1,4 @@
+--colour
+--tty
+--format documentation
+
@@ -0,0 +1,5 @@
+rvm: jruby
+gemfile: Jemfile
+notifications:
+ irc: "irc.freenode.org#travis"
+
13 Jemfile
@@ -0,0 +1,13 @@
+source :rubygems
+
+gem 'travis-core', :path => 'vendor/gems/travis-core'
+
+gem 'jruby-openssl'
+gem 'activerecord-jdbcpostgresql-adapter'
+
+group :test do
+ gem 'rspec', '~> 2.7.0'
+ gem 'database_cleaner', '~> 0.6.7'
+ gem 'mocha', '~> 0.10.0'
+ gem 'webmock', '~> 1.7.7'
+end
@@ -0,0 +1,217 @@
+PATH
+ remote: vendor/gems/travis-core
+ specs:
+ travis-core (0.0.1)
+ actionmailer (~> 3.1.1)
+ actionmailer_inline_css (~> 1.3.0)
+ activerecord (~> 3.1.1)
+ amqp (~> 0.8.2)
+ data_migrations (~> 0.0.1)
+ devise (~> 1.4.2)
+ hashr (~> 0.0.16)
+ oa-oauth (~> 0.3.0)
+ octokit (~> 0.6.5)
+ pusher (~> 0.8.1)
+ rabl (~> 0.5.0)
+ rails (~> 3.1.1)
+ rake (~> 0.9.2)
+ simple_states (~> 0.0.10)
+ thor (~> 0.14.6)
+
+GEM
+ remote: http://rubygems.org/
+ specs:
+ actionmailer (3.1.1)
+ actionpack (= 3.1.1)
+ mail (~> 2.3.0)
+ actionmailer_inline_css (1.3.1)
+ actionmailer (>= 3.0.0)
+ nokogiri (>= 1.4.4)
+ premailer (>= 1.7.1)
+ actionpack (3.1.1)
+ activemodel (= 3.1.1)
+ activesupport (= 3.1.1)
+ builder (~> 3.0.0)
+ erubis (~> 2.7.0)
+ i18n (~> 0.6)
+ rack (~> 1.3.2)
+ rack-cache (~> 1.1)
+ rack-mount (~> 0.8.2)
+ rack-test (~> 0.6.1)
+ sprockets (~> 2.0.2)
+ activemodel (3.1.1)
+ activesupport (= 3.1.1)
+ builder (~> 3.0.0)
+ i18n (~> 0.6)
+ activerecord (3.1.1)
+ activemodel (= 3.1.1)
+ activesupport (= 3.1.1)
+ arel (~> 2.2.1)
+ tzinfo (~> 0.3.29)
+ activerecord-jdbc-adapter (1.2.0)
+ activerecord-jdbcpostgresql-adapter (1.2.0)
+ activerecord-jdbc-adapter (~> 1.2.0)
+ jdbc-postgres (~> 9.0.0)
+ activeresource (3.1.1)
+ activemodel (= 3.1.1)
+ activesupport (= 3.1.1)
+ activesupport (3.1.1)
+ multi_json (~> 1.0)
+ addressable (2.2.6)
+ amq-client (0.8.5)
+ amq-protocol (>= 0.8.0)
+ eventmachine
+ amq-protocol (0.8.3)
+ amqp (0.8.2)
+ amq-client (~> 0.8.5)
+ amq-protocol (~> 0.8.3)
+ eventmachine
+ arel (2.2.1)
+ bcrypt-ruby (3.0.1)
+ bcrypt-ruby (3.0.1-java)
+ bouncy-castle-java (1.5.0146.1)
+ builder (3.0.0)
+ crack (0.1.8)
+ css_parser (1.2.5)
+ addressable
+ data_migrations (0.0.1)
+ activerecord
+ rake
+ database_cleaner (0.6.7)
+ devise (1.4.9)
+ bcrypt-ruby (~> 3.0)
+ orm_adapter (~> 0.0.3)
+ warden (~> 1.0.3)
+ diff-lcs (1.1.3)
+ erubis (2.7.0)
+ eventmachine (0.12.10)
+ eventmachine (0.12.10-java)
+ faraday (0.7.5)
+ addressable (~> 2.2.6)
+ multipart-post (~> 1.1.3)
+ rack (>= 1.1.0, < 2)
+ faraday_middleware (0.7.0)
+ faraday (~> 0.7.3)
+ hashie (1.2.0)
+ hashr (0.0.16)
+ hike (1.2.1)
+ htmlentities (4.3.0)
+ i18n (0.6.0)
+ jdbc-postgres (9.0.801)
+ jruby-openssl (0.7.4)
+ bouncy-castle-java
+ json (1.6.1)
+ json (1.6.1-java)
+ mail (2.3.0)
+ i18n (>= 0.4.0)
+ mime-types (~> 1.16)
+ treetop (~> 1.4.8)
+ metaclass (0.0.1)
+ mime-types (1.17.2)
+ mocha (0.10.0)
+ metaclass (~> 0.0.1)
+ multi_json (1.0.3)
+ multi_xml (0.4.1)
+ multipart-post (1.1.3)
+ nokogiri (1.5.0)
+ nokogiri (1.5.0-java)
+ oa-core (0.3.2)
+ oa-oauth (0.3.2)
+ faraday (~> 0.7.3)
+ multi_json (~> 1.0.0)
+ multi_xml (~> 0.4.0)
+ oa-core (= 0.3.2)
+ oauth (~> 0.4.0)
+ oauth2 (~> 0.5.0)
+ oauth (0.4.5)
+ oauth2 (0.5.1)
+ faraday (~> 0.7.4)
+ multi_json (~> 1.0.3)
+ octokit (0.6.5)
+ addressable (~> 2.2.6)
+ faraday (~> 0.7.4)
+ faraday_middleware (~> 0.7.0)
+ hashie (~> 1.2.0)
+ multi_json (~> 1.0.2)
+ orm_adapter (0.0.5)
+ polyglot (0.3.3)
+ premailer (1.7.3)
+ css_parser (>= 1.1.9)
+ htmlentities (>= 4.0.0)
+ pusher (0.8.4)
+ crack (~> 0.1.0)
+ multi_json (~> 1.0)
+ ruby-hmac (~> 0.4.0)
+ signature (~> 0.1.2)
+ rabl (0.5.1)
+ activesupport (>= 2.3.14)
+ multi_json (~> 1.0.3)
+ rack (1.3.5)
+ rack-cache (1.1)
+ rack (>= 0.4)
+ rack-mount (0.8.3)
+ rack (>= 1.0.0)
+ rack-ssl (1.3.2)
+ rack
+ rack-test (0.6.1)
+ rack (>= 1.0)
+ rails (3.1.1)
+ actionmailer (= 3.1.1)
+ actionpack (= 3.1.1)
+ activerecord (= 3.1.1)
+ activeresource (= 3.1.1)
+ activesupport (= 3.1.1)
+ bundler (~> 1.0)
+ railties (= 3.1.1)
+ railties (3.1.1)
+ actionpack (= 3.1.1)
+ activesupport (= 3.1.1)
+ rack-ssl (~> 1.3.2)
+ rake (>= 0.8.7)
+ rdoc (~> 3.4)
+ thor (~> 0.14.6)
+ rake (0.9.2.2)
+ rdoc (3.11)
+ json (~> 1.4)
+ rspec (2.7.0)
+ rspec-core (~> 2.7.0)
+ rspec-expectations (~> 2.7.0)
+ rspec-mocks (~> 2.7.0)
+ rspec-core (2.7.1)
+ rspec-expectations (2.7.0)
+ diff-lcs (~> 1.1.2)
+ rspec-mocks (2.7.0)
+ ruby-hmac (0.4.0)
+ signature (0.1.2)
+ ruby-hmac
+ simple_states (0.0.10)
+ activesupport
+ hashr (~> 0.0.10)
+ sprockets (2.0.3)
+ hike (~> 1.2)
+ rack (~> 1.0)
+ tilt (~> 1.1, != 1.3.0)
+ thor (0.14.6)
+ tilt (1.3.3)
+ treetop (1.4.10)
+ polyglot
+ polyglot (>= 0.3.1)
+ tzinfo (0.3.31)
+ warden (1.0.6)
+ rack (>= 1.0)
+ webmock (1.7.7)
+ addressable (~> 2.2, > 2.2.5)
+ crack (>= 0.1.7)
+
+PLATFORMS
+ java
+ ruby
+
+DEPENDENCIES
+ activerecord-jdbcpostgresql-adapter
+ database_cleaner (~> 0.6.7)
+ jruby-openssl
+ mocha (~> 0.10.0)
+ rspec (~> 2.7.0)
+ travis-core!
+ webmock (~> 1.7.7)
@@ -0,0 +1 @@
+hub: sh script/jruby -S thor travis:hub:start -e production
@@ -0,0 +1 @@
+# travis-hub
@@ -0,0 +1,14 @@
+require 'rake'
+require 'rspec/core/rake_task'
+
+load 'lib/travis/tasks/travis.rake'
+
+desc 'Run specs'
+RSpec::Core::RakeTask.new do |t|
+ t.pattern = './spec/**/*_spec.rb'
+end
+
+task :default => :spec
+
+
+
@@ -0,0 +1,6 @@
+$: << 'lib'
+$stdout.sync = true
+
+require 'bundler/setup'
+require 'travis/tasks/thor'
+
@@ -0,0 +1,112 @@
+require 'travis'
+require 'amqp'
+require 'multi_json'
+require 'hashr'
+require 'benchmark'
+
+module Travis
+ class Hub
+ autoload :Handler, 'travis/hub/handler'
+ autoload :Job, 'travis/hub/job'
+ autoload :Worker, 'travis/hub/worker'
+
+ include Logging
+
+ REPORTING_KEY = 'reporting.jobs'
+
+ class << self
+ def start
+ Database.connect
+
+ EM.run do
+ prune_workers
+ # cleanup_jobs
+ subscribe
+ end
+ end
+
+ def subscribe
+ new.subscribe
+ end
+
+ def prune_workers
+ interval = Travis.config.workers.prune.interval
+ EM.add_periodic_timer(interval, &::Worker.method(:prune))
+ end
+
+ def cleanup_jobs
+ interval = Travis.config.jobs.retry.interval
+ EM.add_periodic_timer(interval, &::Job.method(:cleanup))
+ end
+ end
+
+ attr_reader :config
+
+ def initialize
+ @config = Travis.config.amqp
+ end
+
+ def subscribe
+ queue.subscribe(:ack => true, &method(:receive))
+ end
+
+ def receive(message, payload)
+ log notice("Handling event #{message.type.inspect} with payload : #{payload.inspect}")
+
+ event = message.type
+ payload = decode(payload)
+ handler = handler_for(event, payload)
+
+ benchmark_and_cache do
+ handler.handle
+ end
+
+ message.ack
+ rescue Exception => e
+ puts e.message, e.backtrace
+ message.ack
+ # message.reject(:requeue => false) # how to decide whether to requeue the message?
+ end
+
+ def heartbeat(message, payload)
+ log notice("Heartbeat: #{payload.inspect}")
+ Worker.heartbeat
+ end
+
+ protected
+
+ def handler_for(event, payload)
+ case event.to_s
+ when /^job/
+ Job.new(event, payload)
+ when /^worker/
+ Worker.new(event, payload)
+ else
+ raise "Unknown message type: #{event.inspect}"
+ end
+ end
+
+ def benchmark_and_cache
+ timing = Benchmark.realtime do
+ ActiveRecord::Base.cache { yield }
+ end
+ log notice("Completed in #{timing.round(4)} seconds")
+ end
+
+ def decode(payload)
+ MultiJson.decode(payload)
+ end
+
+ def connection
+ @connection ||= AMQP.start(config)
+ end
+
+ def channel
+ @channel ||= AMQP::Channel.new(connection).prefetch(config.prefetch)
+ end
+
+ def queue
+ @queue ||= channel.queue(REPORTING_KEY, :durable => true, :exclusive => false)
+ end
+ end
+end
@@ -0,0 +1,15 @@
+require 'hashr'
+
+module Travis
+ class Hub
+ class Handler
+ attr_reader :event, :payload
+
+ def initialize(event, payload)
+ @event = event
+ @payload = Hashr.new(payload)
+ end
+ end
+ end
+end
+
Oops, something went wrong.

0 comments on commit 9d77d5d

Please sign in to comment.