Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@ Gemfile.lock
vendor/erlang
vendor/riak
.ruby-version
tmp
35 changes: 35 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,38 @@ RSpec::Core::RakeTask.new(:ci) do |spec|
spec.rspec_opts = %w[--profile]
end
task :default => :ci


desc "Generate Protocol Buffers message definitions from riak_pb"
task :pb_defs => 'beefcake:pb_defs'

namespace :beefcake do
task :pb_defs => 'lib/riak/client/beefcake/messages.rb'

task :clean do
sh "rm -rf tmp/riak_pb"
sh "rm -rf tmp/riak_kv.pb.rb tmp/riak_search.pb.rb tmp/riak_yokozuna.pb.rb"
end

file 'lib/riak/client/beefcake/messages.rb' => %w{tmp/riak_kv.pb.rb tmp/riak_search.pb.rb tmp/riak_yokozuna.pb.rb} do |t|
sh "cat lib/riak/client/beefcake/header tmp/riak.pb.rb #{t.prerequisites.join ' '} lib/riak/client/beefcake/footer > #{t.name}"
end

file 'tmp/riak_kv.pb.rb' => 'tmp/riak_pb' do |t|
sh "protoc --beefcake_out tmp -I tmp/riak_pb/src tmp/riak_pb/src/riak_kv.proto"
end

file 'tmp/riak_search.pb.rb' => 'tmp/riak_pb' do |t|
sh "protoc --beefcake_out tmp -I tmp/riak_pb/src tmp/riak_pb/src/riak_search.proto"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The messages file needs a change from what protoc generates.

This message needs field replaced with properties.

class RpbSearchDoc
  repeated :fields, RpbPair, 1
end

to this

class RpbSearchDoc
  repeated :properties, RpbPair, 1
end

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I originally changed :fields to :properties because fields is a method defined by Beefcake::Message. Now that development is picking back up, maybe we could fix that in Beefcake?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed here ce4cad1

end

file 'tmp/riak_yokozuna.pb.rb' => 'tmp/riak_pb' do |t|
sh "protoc --beefcake_out tmp -I tmp/riak_pb/src tmp/riak_pb/src/riak_yokozuna.proto"
end

directory 'tmp/riak_pb' do
cd 'tmp' do
sh "git clone -b develop https://github.com/basho/riak_pb.git"
end
end
end
1 change: 1 addition & 0 deletions lib/riak/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
require 'riak/client/decaying'
require 'riak/client/node'
require 'riak/client/search'
require 'riak/client/yokozuna'
require 'riak/client/http_backend'
require 'riak/client/net_http_backend'
require 'riak/client/excon_backend'
Expand Down
4 changes: 4 additions & 0 deletions lib/riak/client/beefcake/footer
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

end
end
end
6 changes: 6 additions & 0 deletions lib/riak/client/beefcake/header
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
require 'beefcake'

module Riak
class Client
# @private
class BeefcakeProtobuffsBackend
7 changes: 7 additions & 0 deletions lib/riak/client/beefcake/message_codes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ module BeefcakeMessageCodes
:CounterUpdateResp => 51,
:CounterGetReq => 52,
:CounterGetResp => 53,
:YokozunaIndexGetReq => 54,
:YokozunaIndexGetResp => 55,
:YokozunaIndexPutReq => 56,
:YokozunaIndexDeleteReq => 57,
:YokozunaSchemaGetReq => 58,
:YokozunaSchemaGetResp => 59,
:YokozunaSchemaPutReq => 60,
}

CODE_TO_MESSAGE = MESSAGE_TO_CODE.invert
Expand Down
49 changes: 49 additions & 0 deletions lib/riak/client/beefcake/message_overlay.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
module Riak
class Client
# @private
class BeefcakeProtobuffsBackend
class RpbIndexReq
module IndexQueryType
EQ = 0
RANGE = 1
end
end

class RpbBucketProps

# "repeated" elements with zero items are indistinguishable
# from a nil, so we have to manage has_precommit/has_postcommit
# flags.
def precommit=(newval)
@precommit = newval
@has_precommit = !!newval
end

def has_precommit=(newval)
@has_precommit = newval
@precommit ||= [] if newval
end

def postcommit=(newval)
@postcommit = newval
@has_postcommit = !!newval
end

def has_postcommit=(newval)
@has_postcommit = newval
@postcommit ||= [] if newval
end
end

class RpbSearchDoc
# rebuild the fields instance method since the
# generated :fields field overwrote this
def fields
self.class.fields
end
repeated :properties, RpbPair, 1
end

end
end
end
Loading