MongoDbStorage connection difficulties

13 views
Skip to first unread message

Damon Torgerson

unread,
Mar 27, 2012, 11:00:18 AM3/27/12
to ruote
Hi,

First off, really impressed with Ruote. More I learn, the better it
gets. I've got it running successfully with file storage and with
redis. I need to implement history so I thought I would switch from
Redis to MongoDB, my main database.

However, it seems I am unable to establish a connection. Ideally, I'd
like to use the :config option but for now, I'm just trying to
connect.

Here's my connection information:

::RuoteDashboard = Ruote::Dashboard.new(

Ruote::MongoDbStorage.new( :connection=>{"host"=>"localhost",
"port"=>27017, "database"=>"studenttransfer_development"}
)
)

and here's the error I get:


/Users/damon/.rvm/gems/ruby-1.9.2-p290/bundler/gems/ruote-mongodb-
f1ad2a74e341/lib/ruote-mongodb/mongodb_storage.rb:196:in
`get_collection': undefined method `collection' for #<Hash:
0x007fe8e349fa38> (NoMethodError)
from /Users/damon/.rvm/gems/ruby-1.9.2-p290/bundler/gems/ruote-
mongodb-f1ad2a74e341/lib/ruote-mongodb/mongodb_storage.rb:85:in `get'
from /Users/damon/.rvm/gems/ruby-1.9.2-p290/bundler/gems/
ruote-4d1b46ef39de/lib/ruote/storage/base.rb:66:in
`replace_engine_configuration'
from /Users/damon/.rvm/gems/ruby-1.9.2-p290/bundler/gems/ruote-
mongodb-f1ad2a74e341/lib/ruote-mongodb/mongodb_storage.rb:17:in
`initialize'
from /Users/damon/projects/studenttransfer/config/application.rb:
66:in `new'
from /Users/damon/projects/studenttransfer/config/application.rb:
66:in `block in <class:Application>'
from /Users/damon/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.3/
lib/active_support/lazy_load_hooks.rb:34:in `call'
from /Users/damon/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.3/
lib/active_support/lazy_load_hooks.rb:34:in `execute_hook'
from /Users/damon/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.3/
lib/active_support/lazy_load_hooks.rb:43:in `block in run_load_hooks'
from /Users/damon/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.3/
lib/active_support/lazy_load_hooks.rb:42:in `each'
from /Users/damon/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.3/
lib/active_support/lazy_load_hooks.rb:42:in `run_load_hooks'
from /Users/damon/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.3/lib/
rails/application/finisher.rb:56:in `block in <module:Finisher>'
from /Users/damon/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.3/lib/
rails/initializable.rb:30:in `instance_exec'
from /Users/damon/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.3/lib/
rails/initializable.rb:30:in `run'
from /Users/damon/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.3/lib/
rails/initializable.rb:55:in `block in run_initializers'
from /Users/damon/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.3/lib/
rails/initializable.rb:54:in `each'
from /Users/damon/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.3/lib/
rails/initializable.rb:54:in `run_initializers'
from /Users/damon/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.3/lib/
rails/application.rb:96:in `initialize!'
from /Users/damon/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.3/lib/
rails/railtie/configurable.rb:30:in `method_missing'
from /Users/damon/projects/studenttransfer/config/environment.rb:5:in
`<top (required)>'
from /Users/damon/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.3/
lib/active_support/dependencies.rb:240:in `require'
from /Users/damon/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.3/
lib/active_support/dependencies.rb:240:in `block in require'
from /Users/damon/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.3/
lib/active_support/dependencies.rb:223:in `block in load_dependency'
from /Users/damon/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.3/
lib/active_support/dependencies.rb:640:in `new_constants_in'
from /Users/damon/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.3/
lib/active_support/dependencies.rb:223:in `load_dependency'
from /Users/damon/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.3/
lib/active_support/dependencies.rb:240:in `require'
from /Users/damon/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.3/lib/
rails/application.rb:83:in `require_environment!'
from /Users/damon/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.3/lib/
rails/commands.rb:39:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'

Any ideas on places I should look?

Regards,
Damon

John Mettraux

unread,
Mar 27, 2012, 4:10:21 PM3/27/12
to ruote

On Wed, Mar 28, 2012 at 04:58:37AM +0900, John Mettraux wrote:
>
> First off, really impressed with Ruote. More I learn, the better it
> gets.

Hello Damon,

welcome to ruote's mailing list.

> I've got it running successfully with file storage and with
> redis. I need to implement history so I thought I would switch from
> Redis to MongoDB, my main database.
>
> However, it seems I am unable to establish a connection. Ideally, I'd
> like to use the :config option but for now, I'm just trying to
> connect.
>
> Here's my connection information:
>
> � � �::RuoteDashboard = Ruote::Dashboard.new(
> Ruote::MongoDbStorage.new(
> :connection=> {
> "host" => "localhost",
> "port" => 27017,
> "database" => "studenttransfer_development" }))
>
> and here's the error I get:
>
> /Users/damon/.rvm/gems/ruby-1.9.2-p290/bundler/gems/ruote-mongodb-
> f1ad2a74e341/lib/ruote-mongodb/mongodb_storage.rb:196:in
> `get_collection': undefined method `collection' for #<Hash:
> 0x007fe8e349fa38> (NoMethodError)

According to the ruote-mongodb source at

https://github.com/PlasticLizard/ruote-mongodb/blob/f1ad2a74e34152d4629c38f74c4d95f0f99d4469/lib/ruote-mongodb/mongodb_storage.rb#L15-18

you're supposed to pass a Mongo object as first parameter.

Please note that there is also "ruote-mon":

https://github.com/jmettraux/ruote-mon

(it's the one I strive to maintain).


Best regards,

--
John Mettraux - http://lambda.io/processi

marsbomber

unread,
Mar 27, 2012, 6:37:15 PM3/27/12
to openwfe...@googlegroups.com
Have you considered implementing work history using mongo in a separate layer and keep ruote to redis? John pointed me to custom ruote service implementation, which I think it's a killer feature.

Damon Torgerson

unread,
Mar 28, 2012, 12:27:50 AM3/28/12
to ruote
John,

Thank you so much for your quick reply and pointer to ruote-mon. I
included it in my Gemfile and was off to the races. I still have some
minor configuration to do but very straightforward.

One question, when I add the service to my dashboard (engine), it
appears as though I have to add what looks like a path.

dashboard = Ruote::Dashboard.new(
Ruote::Worker.new(
Ruote::Mon::Storage.new(
Mongo::Connection.new()['studenttransfer_development'],
{})))
dashboard.add_service('history'
,'ruote/log/storage_history' # <<<<<<<<<<<<<<<<
, 'Ruote::StorageHistory')

I've gone through the code and recognize this as an option but can't
seem to find where the option is defined. I'll admit my Ruby is not as
strong as I would like. What does this option represent?

Thanks again. You've done a wonderful job here.
>  https://github.com/PlasticLizard/ruote-mongodb/blob/f1ad2a74e34152d46...

Damon Torgerson

unread,
Mar 28, 2012, 12:29:44 AM3/28/12
to ruote
Are you referring to the composite storage? It looks pretty slick and
I see the benefits but right now I'm happy to get just one functioning
correctly ;)

John Mettraux

unread,
Mar 28, 2012, 12:48:11 AM3/28/12
to openwfe...@googlegroups.com

On Tue, Mar 27, 2012 at 09:27:50PM -0700, Damon Torgerson wrote:
>
> One question, when I add the service to my dashboard (engine), it
> appears as though I have to add what looks like a path.
>
> dashboard = Ruote::Dashboard.new(
> Ruote::Worker.new(
> Ruote::Mon::Storage.new(
> Mongo::Connection.new()['studenttransfer_development'],
> {})))
> dashboard.add_service('history'
> ,'ruote/log/storage_history' # <<<<<<<<<<<<<<<<
> , 'Ruote::StorageHistory')

Hello Damon,

with the current ruote master, you can directly write:

dashboard.add_service('history', Ruote::StorageHistory)

Reply all
Reply to author
Forward
0 new messages