Mongo Ruby :connecttimeoutms disappeared? - ruby

I've been using the connection option :connecttimeoutms when setting up MongoDB connections using the mongodb ruby gem. Like so:
connection = Connection.from_uri(uri, :connecttimeoutms => connect_timeout)
Now getting warnings that
connecttimeoutms is not a valid option for Mongo::Connection
since a recent bundle update.
Has this disappeared? Does anyone know what I should replace it with?

#sumskyi is absolutely right of course
After such investigation it seems it is now :connect_timeout and is measured in seconds
Thanks

Related

How to connect to Cassandra using ruby

I am new to Cassandra and was trying to achieve some simple
operations like inserting data into cassandra. I am using cassandra gem
to achieve this.
client = Cassandra.new('tags_logs', 'ec2-xxx-xxx-xxx.com:9160')
client.disable_node_auto_discovery!
client.get('tag_data','red')
And I get the following error:
ThriftClient::NoServersAvailable - No live servers in ...
I'm running this code from my local machine. And while I've no problem connecting using cassandra-cli (so it is not a firewall issue), the code refuses to work. It works perfectly when accessing Cassandra on my own local machine.
Any ideas?
Thanks,
Eden.
I recommend you to use this gem I'm developing: https://github.com/hsgubert/cassandra_migrations
It gives access to Cassandra through CQL3 and manages schema with migrations.
Note: it requires Rails.
For future generations: simply change the timeout ...
client = Cassandra.new('tags_logs', 'ec2-example-example-example.com:9160',:connect_timeout => 10000)

How to tell DB size with MongoID on Heroku?

We're using the MongoHQ addon on Heroku, with the Mongoid 3.0 adapter. The addon plans come with a size limit, and Mongo will silently fail writing when the DB limit has been reached (unless configured for safe mode--in which case it'll throw exceptions).
I'm trying to query from within the app how close we are and send an alert if we've reached the limit. How can I run something like the db.stats() command but using Mongoid?
I've found out how to do this in Mongoid 3.x which uses Moped as driver, not the Ruby driver from 10gen.
It was the author of Moped himself who answered a github issue raised on the matter.
Mongoid.default_session.command(collstats: 'collection_name')
This will return the same results as db.stats() from the Mongo console. As an additional bonus, if the collection is capped, there'll be a flag in the return values indicating that.
You can call the ".db" method on your object (e.g. a Document), and do .stats on it.
For example:
MyBlog.db.stats
For verisons prior to Mongoid 3.0.0, Mongoid.master.stats should also work.

ruby sftp error password reset

I am troubleshooting a ruby script that queries a database, creates a csv, and sftps it to another server. The server the script is on is a rhel box, running ruby 1.87 I believe.
Here's the code that does the sftping:
Net::SFTP.start(sftp_site, sftp_user, :password => sftp_pswd) do |sftp|
sftp.upload!(local_filepath,sftp_dir+filename)
end
When executing the script, there is a curious message before it bombs out:
Password Reset
Your password has expired. You are required to change your password to proceed.
This script works on another server, but not this one. A user can sftp from the prompt on this machine. SELinux has been turned off, as it may have had some interference.
Anyway, point being, does anyone have any ideas?
It appeared to be a gem issue (though someone in networking may have worked some magic I am unaware of). The production server had older versions of the net/ssh and net/sftp gems. It had version 1.1.1 and version 1.1.2, respectively, and upgrading those gems to a later version fixed the issue.
Thanks for everyone who offered suggestions!
I would compare the sshd daemon settings (sshd_config), as there's likely an issue in the server that's not working. Perhaps interactive-keyboard authentication is turned on or something like that?

How do I perform a DNS zone transfer (AXFR) using Ruby 1.9?

I'm trying to do a DNS zone transfer and would like to do it using Ruby 1.9. Are there any gems built-in or otherwise that will do this simply?
Take a look at Dnsruby.
If it doesn't do what you need, the author is still maintaining it.
Although I tried dnsruby, I found net-dns to be more intutive.
net-dns is a close port of the Net::DNS from perl, and shares almost all the same methods.
dnsruby ended up being extremely verbose just to do a simple zone transfer.
Installing net-dns was as simple as "gem install net-dns". After creating a new Net::DNS::Resolver object, I used #axfr to perform the zone transfer which worked nicely.
In cases where zone transfer wasn't enabled, I simply used #query or #search.

Is it possible to run locally JRuby on Google App Engine without restarting server on every change?

Unfortunately, GAE requires restart of the server on each code change.
Is it possible to prevent it and have immediate feedback after code save?
Or, can I import Google App Engine's API into my ruby code and run it on Sinatra server? Tried this but it fails on "import com.google.appengine.api" (it doesn't know what 'com' is).
For Sinatra, I use "Rerun" ( http://github.com/alexch/rerun ) which restarts server immediately after a change with minimum wait.
Thanks.
Try http://github.com/rkh/sinatra-reloader
OK, seems like JRuby on Rails doesn't need server restart, Sinatra reloaded/shotgun plugins didn't work well for me.
To run it I copied the files from http://rails-depot.appspot.com/src (the source # http://code.google.com/p/appengine-jruby/source/browse did not contain all the files).

Resources