gateway-cassandra-cql 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.rspec +1 -0
- data/Gemfile +16 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +19 -0
- data/Rakefile +49 -0
- data/VERSION +1 -0
- data/gateway-cassandra-cql.gemspec +65 -0
- data/lib/gateway-cassandra-cql.rb +58 -0
- data/spec/gateway-cassandra-cql_spec.rb +7 -0
- data/spec/spec_helper.rb +12 -0
- metadata +170 -0
data/.document
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/Gemfile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
|
6
|
+
gem "gateway", "~> 0.1.1"
|
7
|
+
gem "cassandra-cql", ">= 1.0.4"
|
8
|
+
|
9
|
+
# Add dependencies to develop your gem here.
|
10
|
+
# Include everything needed to run rake, tests, features, etc.
|
11
|
+
group :development do
|
12
|
+
gem "rspec", ">= 2.8.0"
|
13
|
+
gem "rdoc", ">= 3.12"
|
14
|
+
gem "bundler", ">= 1.0.0"
|
15
|
+
gem "jeweler", ">= 1.8.3"
|
16
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2012 Aaron Qian
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
= gateway-cassandra-cql
|
2
|
+
|
3
|
+
Description goes here.
|
4
|
+
|
5
|
+
== Contributing to gateway-cassandra-cql
|
6
|
+
|
7
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
8
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
9
|
+
* Fork the project.
|
10
|
+
* Start a feature/bugfix branch.
|
11
|
+
* Commit and push until you are happy with your contribution.
|
12
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
13
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
14
|
+
|
15
|
+
== Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2012 Aaron Qian. See LICENSE.txt for
|
18
|
+
further details.
|
19
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "gateway-cassandra-cql"
|
18
|
+
gem.homepage = "http://github.com/aq1018/gateway-cassandra-cql"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{Gateway adapter for cassandra-cql}
|
21
|
+
gem.description = %Q{Gateway adapter for cassandra-cql. Very experiemental.}
|
22
|
+
gem.email = "aq1018@gmail.com"
|
23
|
+
gem.authors = ["Aaron Qian"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rspec/core'
|
29
|
+
require 'rspec/core/rake_task'
|
30
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
31
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
32
|
+
end
|
33
|
+
|
34
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
35
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
36
|
+
spec.rcov = true
|
37
|
+
end
|
38
|
+
|
39
|
+
task :default => :spec
|
40
|
+
|
41
|
+
require 'rdoc/task'
|
42
|
+
Rake::RDocTask.new do |rdoc|
|
43
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
44
|
+
|
45
|
+
rdoc.rdoc_dir = 'rdoc'
|
46
|
+
rdoc.title = "gateway-cassandra-cql #{version}"
|
47
|
+
rdoc.rdoc_files.include('README*')
|
48
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
49
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{gateway-cassandra-cql}
|
8
|
+
s.version = "0.1.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = [%q{Aaron Qian}]
|
12
|
+
s.date = %q{2012-05-09}
|
13
|
+
s.description = %q{Gateway adapter for cassandra-cql. Very experiemental.}
|
14
|
+
s.email = %q{aq1018@gmail.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE.txt",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".rspec",
|
22
|
+
"Gemfile",
|
23
|
+
"LICENSE.txt",
|
24
|
+
"README.rdoc",
|
25
|
+
"Rakefile",
|
26
|
+
"VERSION",
|
27
|
+
"gateway-cassandra-cql.gemspec",
|
28
|
+
"lib/gateway-cassandra-cql.rb",
|
29
|
+
"spec/gateway-cassandra-cql_spec.rb",
|
30
|
+
"spec/spec_helper.rb"
|
31
|
+
]
|
32
|
+
s.homepage = %q{http://github.com/aq1018/gateway-cassandra-cql}
|
33
|
+
s.licenses = [%q{MIT}]
|
34
|
+
s.require_paths = [%q{lib}]
|
35
|
+
s.rubygems_version = %q{1.8.6}
|
36
|
+
s.summary = %q{Gateway adapter for cassandra-cql}
|
37
|
+
|
38
|
+
if s.respond_to? :specification_version then
|
39
|
+
s.specification_version = 3
|
40
|
+
|
41
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
42
|
+
s.add_runtime_dependency(%q<gateway>, ["~> 0.1.1"])
|
43
|
+
s.add_runtime_dependency(%q<cassandra-cql>, [">= 1.0.4"])
|
44
|
+
s.add_development_dependency(%q<rspec>, [">= 2.8.0"])
|
45
|
+
s.add_development_dependency(%q<rdoc>, [">= 3.12"])
|
46
|
+
s.add_development_dependency(%q<bundler>, [">= 1.0.0"])
|
47
|
+
s.add_development_dependency(%q<jeweler>, [">= 1.8.3"])
|
48
|
+
else
|
49
|
+
s.add_dependency(%q<gateway>, ["~> 0.1.1"])
|
50
|
+
s.add_dependency(%q<cassandra-cql>, [">= 1.0.4"])
|
51
|
+
s.add_dependency(%q<rspec>, [">= 2.8.0"])
|
52
|
+
s.add_dependency(%q<rdoc>, [">= 3.12"])
|
53
|
+
s.add_dependency(%q<bundler>, [">= 1.0.0"])
|
54
|
+
s.add_dependency(%q<jeweler>, [">= 1.8.3"])
|
55
|
+
end
|
56
|
+
else
|
57
|
+
s.add_dependency(%q<gateway>, ["~> 0.1.1"])
|
58
|
+
s.add_dependency(%q<cassandra-cql>, [">= 1.0.4"])
|
59
|
+
s.add_dependency(%q<rspec>, [">= 2.8.0"])
|
60
|
+
s.add_dependency(%q<rdoc>, [">= 3.12"])
|
61
|
+
s.add_dependency(%q<bundler>, [">= 1.0.0"])
|
62
|
+
s.add_dependency(%q<jeweler>, [">= 1.8.3"])
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'gateway'
|
2
|
+
require 'cassandra-cql'
|
3
|
+
|
4
|
+
# Have to do this once so that ::CassandraCQL::Thrift::Client::TransportException
|
5
|
+
# is factoried out of thrift client factory... :(
|
6
|
+
ThriftClient.new CassandraCQL::Thrift::Client, []
|
7
|
+
|
8
|
+
module Gateway
|
9
|
+
class CassandraCQL < Gateway::Base
|
10
|
+
categorize_error [
|
11
|
+
::CassandraCQL::Thrift::Client::TransportException,
|
12
|
+
::CassandraCQL::Thrift::UnavailableException
|
13
|
+
], :as => :bad_gateway
|
14
|
+
|
15
|
+
categorize_error [
|
16
|
+
::CassandraCQL::Thrift::TimedOutException
|
17
|
+
], :as => :timeout
|
18
|
+
|
19
|
+
categorize_error [
|
20
|
+
::CassandraCQL::Thrift::Client::TransportException,
|
21
|
+
::CassandraCQL::Thrift::UnavailableException,
|
22
|
+
::CassandraCQL::Thrift::TimedOutException
|
23
|
+
], :as => :retry
|
24
|
+
|
25
|
+
alias :__execute__ :execute
|
26
|
+
|
27
|
+
def execute *args
|
28
|
+
arguments = args.dup
|
29
|
+
statement = args.shift
|
30
|
+
block = args.pop if block_given?
|
31
|
+
opts = args.last.is_a?(Hash) ? args.pop : {}
|
32
|
+
bind_vars = args
|
33
|
+
|
34
|
+
__execute__('cql', statement.to_s, opts) do |conn|
|
35
|
+
if block
|
36
|
+
conn.execute statement, *bind_vars, &block
|
37
|
+
else
|
38
|
+
conn.execute statement, *bind_vars
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
protected
|
44
|
+
|
45
|
+
def connect
|
46
|
+
opt = options[:keyspace] ? {:keyspace => options[:keyspace]} : {}
|
47
|
+
CassandraCQL::Database.new options[:servers], opt
|
48
|
+
end
|
49
|
+
|
50
|
+
def disconnect(conn)
|
51
|
+
conn.disconnect!
|
52
|
+
end
|
53
|
+
|
54
|
+
def reconnect(conn)
|
55
|
+
conn.reset!
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
require 'rspec'
|
4
|
+
require 'gateway-cassandra-cql'
|
5
|
+
|
6
|
+
# Requires supporting files with custom matchers and macros, etc,
|
7
|
+
# in ./support/ and its subdirectories.
|
8
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
9
|
+
|
10
|
+
RSpec.configure do |config|
|
11
|
+
|
12
|
+
end
|
metadata
ADDED
@@ -0,0 +1,170 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gateway-cassandra-cql
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 0
|
10
|
+
version: 0.1.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Aaron Qian
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2012-05-09 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
22
|
+
none: false
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
hash: 25
|
27
|
+
segments:
|
28
|
+
- 0
|
29
|
+
- 1
|
30
|
+
- 1
|
31
|
+
version: 0.1.1
|
32
|
+
version_requirements: *id001
|
33
|
+
name: gateway
|
34
|
+
prerelease: false
|
35
|
+
type: :runtime
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
38
|
+
none: false
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
hash: 31
|
43
|
+
segments:
|
44
|
+
- 1
|
45
|
+
- 0
|
46
|
+
- 4
|
47
|
+
version: 1.0.4
|
48
|
+
version_requirements: *id002
|
49
|
+
name: cassandra-cql
|
50
|
+
prerelease: false
|
51
|
+
type: :runtime
|
52
|
+
- !ruby/object:Gem::Dependency
|
53
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
hash: 47
|
59
|
+
segments:
|
60
|
+
- 2
|
61
|
+
- 8
|
62
|
+
- 0
|
63
|
+
version: 2.8.0
|
64
|
+
version_requirements: *id003
|
65
|
+
name: rspec
|
66
|
+
prerelease: false
|
67
|
+
type: :development
|
68
|
+
- !ruby/object:Gem::Dependency
|
69
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
70
|
+
none: false
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
hash: 31
|
75
|
+
segments:
|
76
|
+
- 3
|
77
|
+
- 12
|
78
|
+
version: "3.12"
|
79
|
+
version_requirements: *id004
|
80
|
+
name: rdoc
|
81
|
+
prerelease: false
|
82
|
+
type: :development
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
85
|
+
none: false
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
hash: 23
|
90
|
+
segments:
|
91
|
+
- 1
|
92
|
+
- 0
|
93
|
+
- 0
|
94
|
+
version: 1.0.0
|
95
|
+
version_requirements: *id005
|
96
|
+
name: bundler
|
97
|
+
prerelease: false
|
98
|
+
type: :development
|
99
|
+
- !ruby/object:Gem::Dependency
|
100
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
101
|
+
none: false
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
hash: 49
|
106
|
+
segments:
|
107
|
+
- 1
|
108
|
+
- 8
|
109
|
+
- 3
|
110
|
+
version: 1.8.3
|
111
|
+
version_requirements: *id006
|
112
|
+
name: jeweler
|
113
|
+
prerelease: false
|
114
|
+
type: :development
|
115
|
+
description: Gateway adapter for cassandra-cql. Very experiemental.
|
116
|
+
email: aq1018@gmail.com
|
117
|
+
executables: []
|
118
|
+
|
119
|
+
extensions: []
|
120
|
+
|
121
|
+
extra_rdoc_files:
|
122
|
+
- LICENSE.txt
|
123
|
+
- README.rdoc
|
124
|
+
files:
|
125
|
+
- .document
|
126
|
+
- .rspec
|
127
|
+
- Gemfile
|
128
|
+
- LICENSE.txt
|
129
|
+
- README.rdoc
|
130
|
+
- Rakefile
|
131
|
+
- VERSION
|
132
|
+
- gateway-cassandra-cql.gemspec
|
133
|
+
- lib/gateway-cassandra-cql.rb
|
134
|
+
- spec/gateway-cassandra-cql_spec.rb
|
135
|
+
- spec/spec_helper.rb
|
136
|
+
homepage: http://github.com/aq1018/gateway-cassandra-cql
|
137
|
+
licenses:
|
138
|
+
- MIT
|
139
|
+
post_install_message:
|
140
|
+
rdoc_options: []
|
141
|
+
|
142
|
+
require_paths:
|
143
|
+
- lib
|
144
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
145
|
+
none: false
|
146
|
+
requirements:
|
147
|
+
- - ">="
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
hash: 3
|
150
|
+
segments:
|
151
|
+
- 0
|
152
|
+
version: "0"
|
153
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
154
|
+
none: false
|
155
|
+
requirements:
|
156
|
+
- - ">="
|
157
|
+
- !ruby/object:Gem::Version
|
158
|
+
hash: 3
|
159
|
+
segments:
|
160
|
+
- 0
|
161
|
+
version: "0"
|
162
|
+
requirements: []
|
163
|
+
|
164
|
+
rubyforge_project:
|
165
|
+
rubygems_version: 1.8.6
|
166
|
+
signing_key:
|
167
|
+
specification_version: 3
|
168
|
+
summary: Gateway adapter for cassandra-cql
|
169
|
+
test_files: []
|
170
|
+
|