hello_thrift 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 256aa644753223a30bb87237af29ec91f949f5a4
4
+ data.tar.gz: 21d1f00ee18eecf1708e2c1d035472ed151e0ec0
5
+ SHA512:
6
+ metadata.gz: 794eb135fdefce5f1bafaa4f8b75fd1ae04f96d48c24e3b85776e168e1fd4c131e8f29a571af07ec55d5a721f8ad86e6434b2d0f6833b560aac9bb92d788da34
7
+ data.tar.gz: 603fcddfcf4aaf54aa1f50bd318a145944e448f78131c6b75376be46fb4efae1233547053f0aa976592ed591d121ea42e8a936c45cea9ceebf4d92ee252dc8ce
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in hello_thrift.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Bill Siggelkow
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,55 @@
1
+ # HelloThrift
2
+
3
+ This is a simple "Hello World" usage of [Thrift RPC](https://thrift.apache.org/) in Ruby. It was developed
4
+ to test simple integration of a Thrift service.
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'hello_thrift'
12
+ ```
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install hello_thrift
21
+
22
+ ## Usage
23
+
24
+ ### Start a HelloThrift::Server
25
+
26
+ $ bundle exec hellothrift.start
27
+
28
+ ### Use the HelloThrift::Client to call the server
29
+
30
+ ```ruby
31
+ client = HelloThrift::Client.new
32
+ client.say_hello( 'Bob' )
33
+ #=> "Hello, Bob from Thrift!"
34
+ ```
35
+
36
+ ## Re-generating from new IDL
37
+
38
+ The hello_service.thrift IDL (interface definition) looks as follows:
39
+ ```thrift
40
+ service HelloService {
41
+ string say_hello(1: string name)
42
+ }
43
+ ```
44
+
45
+ Feel free to experiment with [modifying this interface](https://thrift.apache.org/docs/idl). You can then regenerate the Ruby client and server stubs using the following command:
46
+
47
+ $ thrift --gen rb -out ../lib/hello_thrift/hello_service hello_service.thrift
48
+
49
+ ## Contributing
50
+
51
+ 1. Fork it ( https://github.com/[my-github-username]/hello_thrift/fork )
52
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
53
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
54
+ 4. Push to the branch (`git push origin my-new-feature`)
55
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+ require 'hello_thrift'
3
+
4
+ server = HelloThrift::Server.new
5
+ puts "Starting server ..."
6
+ server.serve
7
+ puts "Done."
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'hello_thrift/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "hello_thrift"
8
+ spec.version = HelloThrift::VERSION
9
+ spec.authors = ["Bill Siggelkow"]
10
+ spec.email = ["bill.siggelkow@blinqmedia.com"]
11
+ spec.summary = 'Hello thrift'
12
+ spec.description = 'Thrifyt'
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_dependency 'thrift'
24
+ spec.add_dependency 'thin'
25
+ end
@@ -0,0 +1,42 @@
1
+ require_relative 'hello_service/hello_service'
2
+
3
+ module HelloThrift
4
+
5
+ class Client
6
+
7
+ def initialize(options={})
8
+ port = options[:port] || 9090
9
+ @transport = Thrift::BufferedTransport.new(Thrift::Socket.new('localhost', port))
10
+ protocol = Thrift::BinaryProtocol.new(@transport)
11
+ @client = HelloService::Client.new(protocol)
12
+ end
13
+
14
+ def say_hello(name)
15
+ safe_transport do
16
+ @client.say_hello(name)
17
+ end
18
+ end
19
+
20
+ private
21
+
22
+ def safe_transport
23
+ begin
24
+ @transport.open
25
+ return yield
26
+ ensure
27
+ @transport.close
28
+ end
29
+ end
30
+
31
+ end
32
+
33
+ end
34
+
35
+ # client = HelloThrift::Client.new
36
+
37
+ # loop do
38
+ # print "What is your name? "
39
+ # input = gets.strip
40
+ # break if input == 'quit'
41
+ # puts client.say_hello(input)
42
+ # end
@@ -0,0 +1,78 @@
1
+ #
2
+ # Autogenerated by Thrift Compiler (0.9.1)
3
+ #
4
+ # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5
+ #
6
+
7
+ require 'thrift'
8
+ require_relative 'hello_service_types'
9
+
10
+ module HelloService
11
+ class Client
12
+ include ::Thrift::Client
13
+
14
+ def say_hello(name)
15
+ send_say_hello(name)
16
+ return recv_say_hello()
17
+ end
18
+
19
+ def send_say_hello(name)
20
+ send_message('say_hello', Say_hello_args, :name => name)
21
+ end
22
+
23
+ def recv_say_hello()
24
+ result = receive_message(Say_hello_result)
25
+ return result.success unless result.success.nil?
26
+ raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'say_hello failed: unknown result')
27
+ end
28
+
29
+ end
30
+
31
+ class Processor
32
+ include ::Thrift::Processor
33
+
34
+ def process_say_hello(seqid, iprot, oprot)
35
+ args = read_args(iprot, Say_hello_args)
36
+ result = Say_hello_result.new()
37
+ result.success = @handler.say_hello(args.name)
38
+ write_result(result, oprot, 'say_hello', seqid)
39
+ end
40
+
41
+ end
42
+
43
+ # HELPER FUNCTIONS AND STRUCTURES
44
+
45
+ class Say_hello_args
46
+ include ::Thrift::Struct, ::Thrift::Struct_Union
47
+ NAME = 1
48
+
49
+ FIELDS = {
50
+ NAME => {:type => ::Thrift::Types::STRING, :name => 'name'}
51
+ }
52
+
53
+ def struct_fields; FIELDS; end
54
+
55
+ def validate
56
+ end
57
+
58
+ ::Thrift::Struct.generate_accessors self
59
+ end
60
+
61
+ class Say_hello_result
62
+ include ::Thrift::Struct, ::Thrift::Struct_Union
63
+ SUCCESS = 0
64
+
65
+ FIELDS = {
66
+ SUCCESS => {:type => ::Thrift::Types::STRING, :name => 'success'}
67
+ }
68
+
69
+ def struct_fields; FIELDS; end
70
+
71
+ def validate
72
+ end
73
+
74
+ ::Thrift::Struct.generate_accessors self
75
+ end
76
+
77
+ end
78
+
@@ -0,0 +1,9 @@
1
+ #
2
+ # Autogenerated by Thrift Compiler (0.9.1)
3
+ #
4
+ # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5
+ #
6
+
7
+ require 'thrift'
8
+ require 'hello_service_types'
9
+
@@ -0,0 +1,8 @@
1
+ #
2
+ # Autogenerated by Thrift Compiler (0.9.1)
3
+ #
4
+ # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5
+ #
6
+
7
+ require 'thrift'
8
+
@@ -0,0 +1,29 @@
1
+ require_relative 'hello_service/hello_service'
2
+
3
+ module HelloThrift
4
+
5
+ class Handler
6
+ def say_hello(name)
7
+ puts "Saying hello to #{name}"
8
+ "Hello, #{name} from Thrift!"
9
+ end
10
+ end
11
+
12
+ class Server
13
+ attr_reader :service
14
+
15
+ def initialize(options={})
16
+ port = options[:port] || 9090
17
+ handler = Handler.new
18
+ processor = HelloService::Processor.new(handler)
19
+ transport = Thrift::ServerSocket.new(port)
20
+ transportFactory = Thrift::BufferedTransportFactory.new
21
+ @service = Thrift::SimpleServer.new(processor, transport, transportFactory)
22
+ end
23
+
24
+ def serve
25
+ service.serve
26
+ end
27
+ end
28
+
29
+ end
@@ -0,0 +1,3 @@
1
+ module HelloThrift
2
+ VERSION = "0.0.3"
3
+ end
@@ -0,0 +1,3 @@
1
+ require 'hello_thrift/version'
2
+ require 'hello_thrift/client'
3
+ require 'hello_thrift/server'
@@ -0,0 +1,3 @@
1
+ service HelloService {
2
+ string say_hello(1: string name)
3
+ }
metadata ADDED
@@ -0,0 +1,116 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hello_thrift
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
5
+ platform: ruby
6
+ authors:
7
+ - Bill Siggelkow
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-10-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: thrift
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: thin
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Thrifyt
70
+ email:
71
+ - bill.siggelkow@blinqmedia.com
72
+ executables:
73
+ - hellothrift.start
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - Gemfile
79
+ - LICENSE.txt
80
+ - README.md
81
+ - Rakefile
82
+ - bin/hellothrift.start
83
+ - hello_thrift.gemspec
84
+ - lib/hello_thrift.rb
85
+ - lib/hello_thrift/client.rb
86
+ - lib/hello_thrift/hello_service/hello_service.rb
87
+ - lib/hello_thrift/hello_service/hello_service_constants.rb
88
+ - lib/hello_thrift/hello_service/hello_service_types.rb
89
+ - lib/hello_thrift/server.rb
90
+ - lib/hello_thrift/version.rb
91
+ - thrift/hello_service.thrift
92
+ homepage: ''
93
+ licenses:
94
+ - MIT
95
+ metadata: {}
96
+ post_install_message:
97
+ rdoc_options: []
98
+ require_paths:
99
+ - lib
100
+ required_ruby_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ required_rubygems_version: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ requirements: []
111
+ rubyforge_project:
112
+ rubygems_version: 2.2.2
113
+ signing_key:
114
+ specification_version: 4
115
+ summary: Hello thrift
116
+ test_files: []