ileitch/rapns — pull request #86 by shaokun (2012-12-09 13:14:43+00:00)
Title: Queue and QueueStatus for rapns

Specifying a queue parameter when starting up a rapns instance, in order to support multiple instances of rapns in the same server or multiple servers.

Also added a QueueStatus ActiveRecord to monitor the sent_count, failed_count and heart_beart information of the rapns instance.

In my project, I start 10 instances in each server and there are 3 servers totally, all the 30 instances working fine so far.

This is basically a draft of my idea to run the rapns in multiple servers and I failed to run the `rake test`.
So no spec test for this yet.

Please let me know if this idea work or not. And then I could start to add test cases for it.

Below it's the problem when I run `ADAPTER=mysql2 bundle exec rake`.

```
Using mysql2 adapter.
-- drop_table(:rapns_notifications)
-- create_table(:rapns_notifications)
/Users/wushaokun/.rvm/gems/ruby-1.9.2-p320@rapns/gems/activerecord-3.2.9/lib/active_record/connection_adapters/mysql_adapter.rb:411:in `real_connect': Access denied for user ''@'localhost' to database 'rapns_test' (Mysql::Error)
from /Users/wushaokun/.rvm/gems/ruby-1.9.2-p320@rapns/gems/activerecord-3.2.9/lib/active_record/connection_adapters/mysql_adapter.rb:411:in `connect'
from /Users/wushaokun/.rvm/gems/ruby-1.9.2-p320@rapns/gems/activerecord-3.2.9/lib/active_record/connection_adapters/mysql_adapter.rb:131:in `initialize'
from /Users/wushaokun/.rvm/gems/ruby-1.9.2-p320@rapns/gems/activerecord-3.2.9/lib/active_record/connection_adapters/mysql_adapter.rb:38:in `new'
from /Users/wushaokun/.rvm/gems/ruby-1.9.2-p320@rapns/gems/activerecord-3.2.9/lib/active_record/connection_adapters/mysql_adapter.rb:38:in `mysql_connection'
from /Users/wushaokun/.rvm/gems/ruby-1.9.2-p320@rapns/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:315:in `new_connection'
from /Users/wushaokun/.rvm/gems/ruby-1.9.2-p320@rapns/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:325:in `checkout_new_connection'
from /Users/wushaokun/.rvm/gems/ruby-1.9.2-p320@rapns/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:247:in `block (2 levels) in checkout'
from /Users/wushaokun/.rvm/gems/ruby-1.9.2-p320@rapns/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:242:in `loop'
from /Users/wushaokun/.rvm/gems/ruby-1.9.2-p320@rapns/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:242:in `block in checkout'
from /Users/wushaokun/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
from /Users/wushaokun/.rvm/gems/ruby-1.9.2-p320@rapns/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:239:in `checkout'
from /Users/wushaokun/.rvm/gems/ruby-1.9.2-p320@rapns/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:102:in `block in connection'
from /Users/wushaokun/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
from /Users/wushaokun/.rvm/gems/ruby-1.9.2-p320@rapns/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:101:in `connection'
from /Users/wushaokun/.rvm/gems/ruby-1.9.2-p320@rapns/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:410:in `retrieve_connection'
from /Users/wushaokun/.rvm/gems/ruby-1.9.2-p320@rapns/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_specification.rb:171:in `retrieve_connection'
from /Users/wushaokun/.rvm/gems/ruby-1.9.2-p320@rapns/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_specification.rb:145:in `connection'
from /Users/wushaokun/.rvm/gems/ruby-1.9.2-p320@rapns/gems/activerecord-3.2.9/lib/active_record/migration.rb:452:in `connection'
from /Users/wushaokun/.rvm/gems/ruby-1.9.2-p320@rapns/gems/activerecord-3.2.9/lib/active_record/migration.rb:465:in `block in method_missing'
from /Users/wushaokun/.rvm/gems/ruby-1.9.2-p320@rapns/gems/activerecord-3.2.9/lib/active_record/migration.rb:438:in `block in say_with_time'
from /Users/wushaokun/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/benchmark.rb:295:in `measure'
from /Users/wushaokun/.rvm/gems/ruby-1.9.2-p320@rapns/gems/activerecord-3.2.9/lib/active_record/migration.rb:438:in `say_with_time'
from /Users/wushaokun/.rvm/gems/ruby-1.9.2-p320@rapns/gems/activerecord-3.2.9/lib/active_record/migration.rb:458:in `method_missing'
from /Users/wushaokun/.rvm/gems/ruby-1.9.2-p320@rapns/gems/activerecord-3.2.9/lib/active_record/migration.rb:334:in `method_missing'
from /Users/wushaokun/workspace/rapns/lib/generators/templates/create_rapns_notifications.rb:3:in `up'
from /Users/wushaokun/workspace/rapns/spec/unit_spec_helper.rb:50:in `block in '
from /Users/wushaokun/workspace/rapns/spec/unit_spec_helper.rb:47:in `each'
from /Users/wushaokun/workspace/rapns/spec/unit_spec_helper.rb:47:in `'
from /Users/wushaokun/workspace/rapns/spec/acceptance_spec_helper.rb:1:in `require'
from /Users/wushaokun/workspace/rapns/spec/acceptance_spec_helper.rb:1:in `'
from /Users/wushaokun/workspace/rapns/spec/acceptance/gcm_upgrade_spec.rb:1:in `require'
from /Users/wushaokun/workspace/rapns/spec/acceptance/gcm_upgrade_spec.rb:1:in `'
from /Users/wushaokun/.rvm/gems/ruby-1.9.2-p320@rapns/gems/rspec-core-2.12.1/lib/rspec/core/configuration.rb:789:in `load'
from /Users/wushaokun/.rvm/gems/ruby-1.9.2-p320@rapns/gems/rspec-core-2.12.1/lib/rspec/core/configuration.rb:789:in `block in load_spec_files'
from /Users/wushaokun/.rvm/gems/ruby-1.9.2-p320@rapns/gems/rspec-core-2.12.1/lib/rspec/core/configuration.rb:789:in `each'
from /Users/wushaokun/.rvm/gems/ruby-1.9.2-p320@rapns/gems/rspec-core-2.12.1/lib/rspec/core/configuration.rb:789:in `load_spec_files'
from /Users/wushaokun/.rvm/gems/ruby-1.9.2-p320@rapns/gems/rspec-core-2.12.1/lib/rspec/core/command_line.rb:22:in `run'
from /Users/wushaokun/.rvm/gems/ruby-1.9.2-p320@rapns/gems/rspec-core-2.12.1/lib/rspec/core/runner.rb:80:in `run'
from /Users/wushaokun/.rvm/gems/ruby-1.9.2-p320@rapns/gems/rspec-core-2.12.1/lib/rspec/core/runner.rb:17:in `block in autorun'
```