Skip to content
This repository has been archived by the owner on Sep 18, 2021. It is now read-only.

Commit

Permalink
updated to thrift that catches exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
fizx committed Oct 18, 2010
1 parent e18e4ba commit f05ed0a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 154 deletions.
2 changes: 1 addition & 1 deletion flockdb.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Gem::Specification.new do |s|

s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Matt Freels", "Rael Dornfest", "Nick Kallen"]
s.date = %q{2010-09-03}
s.date = %q{2010-10-18}
s.description = %q{Get your flock on in Ruby.}
s.email = %q{freels@twitter.com}
s.extra_rdoc_files = [
Expand Down
151 changes: 20 additions & 131 deletions lib/flock/gen-rb/flock_d_b.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,37 +45,6 @@ def recv_get()
raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'get failed: unknown result')
end

def get_metadata(source_id, graph_id)
send_get_metadata(source_id, graph_id)
return recv_get_metadata()
end

def send_get_metadata(source_id, graph_id)
send_message('get_metadata', Get_metadata_args, :source_id => source_id, :graph_id => graph_id)
end

def recv_get_metadata()
result = receive_message(Get_metadata_result)
return result.success unless result.success.nil?
raise result.ex unless result.ex.nil?
raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'get_metadata failed: unknown result')
end

def set_state_id(source_id, graph_id, state_id)
send_set_state_id(source_id, graph_id, state_id)
recv_set_state_id()
end

def send_set_state_id(source_id, graph_id, state_id)
send_message('set_state_id', Set_state_id_args, :source_id => source_id, :graph_id => graph_id, :state_id => state_id)
end

def recv_set_state_id()
result = receive_message(Set_state_id_result)
raise result.ex unless result.ex.nil?
return
end

def select2(queries)
send_select2(queries)
return recv_select2()
Expand Down Expand Up @@ -151,6 +120,7 @@ def send_count(operations)
def recv_count()
result = receive_message(Count_result)
return result.success unless result.success.nil?
raise result.ex unless result.ex.nil?
raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'count failed: unknown result')
end

Expand All @@ -166,6 +136,7 @@ def send_select(operations, page)
def recv_select()
result = receive_message(Select_result)
return result.success unless result.success.nil?
raise result.ex unless result.ex.nil?
raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'select failed: unknown result')
end

Expand Down Expand Up @@ -196,28 +167,6 @@ def process_get(seqid, iprot, oprot)
write_result(result, oprot, 'get', seqid)
end

def process_get_metadata(seqid, iprot, oprot)
args = read_args(iprot, Get_metadata_args)
result = Get_metadata_result.new()
begin
result.success = @handler.get_metadata(args.source_id, args.graph_id)
rescue Flock::Edges::FlockException => ex
result.ex = ex
end
write_result(result, oprot, 'get_metadata', seqid)
end

def process_set_state_id(seqid, iprot, oprot)
args = read_args(iprot, Set_state_id_args)
result = Set_state_id_result.new()
begin
@handler.set_state_id(args.source_id, args.graph_id, args.state_id)
rescue Flock::Edges::FlockException => ex
result.ex = ex
end
write_result(result, oprot, 'set_state_id', seqid)
end

def process_select2(seqid, iprot, oprot)
args = read_args(iprot, Select2_args)
result = Select2_result.new()
Expand Down Expand Up @@ -265,14 +214,22 @@ def process_execute(seqid, iprot, oprot)
def process_count(seqid, iprot, oprot)
args = read_args(iprot, Count_args)
result = Count_result.new()
result.success = @handler.count(args.operations)
begin
result.success = @handler.count(args.operations)
rescue Flock::Edges::FlockException => ex
result.ex = ex
end
write_result(result, oprot, 'count', seqid)
end

def process_select(seqid, iprot, oprot)
args = read_args(iprot, Select_args)
result = Select_result.new()
result.success = @handler.select(args.operations, args.page)
begin
result.success = @handler.select(args.operations, args.page)
rescue Flock::Edges::FlockException => ex
result.ex = ex
end
write_result(result, oprot, 'select', seqid)
end

Expand Down Expand Up @@ -356,78 +313,6 @@ def validate

end

class Get_metadata_args
include ::Thrift::Struct
SOURCE_ID = 1
GRAPH_ID = 2

::Thrift::Struct.field_accessor self, :source_id, :graph_id
FIELDS = {
SOURCE_ID => {:type => ::Thrift::Types::I64, :name => 'source_id'},
GRAPH_ID => {:type => ::Thrift::Types::I32, :name => 'graph_id'}
}

def struct_fields; FIELDS; end

def validate
end

end

class Get_metadata_result
include ::Thrift::Struct
SUCCESS = 0
EX = 1

::Thrift::Struct.field_accessor self, :success, :ex
FIELDS = {
SUCCESS => {:type => ::Thrift::Types::STRUCT, :name => 'success', :class => Flock::Edges::Metadata},
EX => {:type => ::Thrift::Types::STRUCT, :name => 'ex', :class => Flock::Edges::FlockException}
}

def struct_fields; FIELDS; end

def validate
end

end

class Set_state_id_args
include ::Thrift::Struct
SOURCE_ID = 1
GRAPH_ID = 2
STATE_ID = 3

::Thrift::Struct.field_accessor self, :source_id, :graph_id, :state_id
FIELDS = {
SOURCE_ID => {:type => ::Thrift::Types::I64, :name => 'source_id'},
GRAPH_ID => {:type => ::Thrift::Types::I32, :name => 'graph_id'},
STATE_ID => {:type => ::Thrift::Types::I32, :name => 'state_id'}
}

def struct_fields; FIELDS; end

def validate
end

end

class Set_state_id_result
include ::Thrift::Struct
EX = 1

::Thrift::Struct.field_accessor self, :ex
FIELDS = {
EX => {:type => ::Thrift::Types::STRUCT, :name => 'ex', :class => Flock::Edges::FlockException}
}

def struct_fields; FIELDS; end

def validate
end

end

class Select2_args
include ::Thrift::Struct
QUERIES = 1
Expand Down Expand Up @@ -581,10 +466,12 @@ def validate
class Count_result
include ::Thrift::Struct
SUCCESS = 0
EX = 1

::Thrift::Struct.field_accessor self, :success
::Thrift::Struct.field_accessor self, :success, :ex
FIELDS = {
SUCCESS => {:type => ::Thrift::Types::I32, :name => 'success'}
SUCCESS => {:type => ::Thrift::Types::I32, :name => 'success'},
EX => {:type => ::Thrift::Types::STRUCT, :name => 'ex', :class => Flock::Edges::FlockException}
}

def struct_fields; FIELDS; end
Expand Down Expand Up @@ -615,10 +502,12 @@ def validate
class Select_result
include ::Thrift::Struct
SUCCESS = 0
EX = 1

::Thrift::Struct.field_accessor self, :success
::Thrift::Struct.field_accessor self, :success, :ex
FIELDS = {
SUCCESS => {:type => ::Thrift::Types::STRUCT, :name => 'success', :class => Flock::Edges::Results}
SUCCESS => {:type => ::Thrift::Types::STRUCT, :name => 'success', :class => Flock::Edges::Results},
EX => {:type => ::Thrift::Types::STRUCT, :name => 'ex', :class => Flock::Edges::FlockException}
}

def struct_fields; FIELDS; end
Expand Down
22 changes: 0 additions & 22 deletions lib/flock/gen-rb/flockdb_types.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,28 +103,6 @@ def validate

end

class Metadata
include ::Thrift::Struct
SOURCE_ID = 1
STATE_ID = 2
COUNT = 3
UPDATED_AT = 4

::Thrift::Struct.field_accessor self, :source_id, :state_id, :count, :updated_at
FIELDS = {
SOURCE_ID => {:type => ::Thrift::Types::I64, :name => 'source_id'},
STATE_ID => {:type => ::Thrift::Types::I32, :name => 'state_id'},
COUNT => {:type => ::Thrift::Types::I32, :name => 'count'},
UPDATED_AT => {:type => ::Thrift::Types::I32, :name => 'updated_at'}
}

def struct_fields; FIELDS; end

def validate
end

end

class Edge
include ::Thrift::Struct
SOURCE_ID = 1
Expand Down

0 comments on commit f05ed0a

Please sign in to comment.