OrientdbClient
Ruby client for Orientdb. Probably not quite ready for production yet. Inspired by https://github.com/veny/orientdb4r
Goals:
- speed (as much as possible with ruby)
- fine-grained handling of Orientdb errors, via rich set of ruby exceptions
Tested on:
- 2.1.5
- 2.0.6 - specs may fail due to Orientdb bug with deleting database (https://github.com/orientechnologies/orientdb/issues/3746)
- 2.0.4
- 2.0.2
CI tests with Travis currently only run non-integration tests (i.e. they don't actually hit an Orientdb server).
Installation
Add this line to your application's Gemfile:
gem 'orientdb_client'
And then execute:
$ bundle
Or install it yourself as:
$ gem install orientdb_client
Usage
# basic usage
my_client = OrientdbClient.client
# connect to default Orientdb database
my_client.connect(username: 'root', password: 'YOURPASSWORD', db: 'GratefulDeadConcerts')
my_client.query('select * from V')
# create database
my_client.create_database('new_db', 'plocal', 'graph')
# use a different logger
class MyLogger
def info()
puts "my message: #{}"
end
end
Orientdb::logger = MyLogger.new
# use a different HttpAdapter
require 'orientdb_client'
require 'orientdb_client/http_adapters/curb_adapter'
client = OrientdbClient.client(adapter: 'CurbAdapter')
HTTP Adapters
OrientdbClient currently supports Typhoeus and Curb HTTP adapters.
Benchmarks:
#tc is typhoeus client, cc is curb client
require 'benchmark'
Benchmark.bmbm do |x|
x.report('typhoeus') { 100.times { tc.query('select * from V') } }
x.report('curb') { 100.times { cc.query('select * from V') } }
end
Rehearsal --------------------------------------------
typhoeus 0.100000 0.010000 0.110000 ( 0.392666)
curb 0.060000 0.000000 0.060000 ( 0.347496)
----------------------------------- total: 0.170000sec
user system total real
typhoeus 0.100000 0.010000 0.110000 ( 0.387320)
curb 0.060000 0.010000 0.070000 ( 0.331764)
Development
Launch pry session with the gem: rake console, in pry use reload! to reload all gem files.
Run tests: rake db:test:create (consult test.rb for information on customizing auth credentials via env variables).
Turn on/off rudimentary debug mode with client.debug = true/false.
Contributing
- Fork it ( https://github.com/[my-github-username]/orientdb_client/fork )
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request