stark-http 1.0.0

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.
@@ -0,0 +1,23 @@
1
+ # -*- ruby -*-
2
+
3
+ require 'autotest/restart'
4
+
5
+ # Autotest.add_hook :initialize do |at|
6
+ # at.extra_files << "../some/external/dependency.rb"
7
+ #
8
+ # at.libs << ":../some/external"
9
+ #
10
+ # at.add_exception 'vendor'
11
+ #
12
+ # at.add_mapping(/dependency.rb/) do |f, _|
13
+ # at.files_matching(/test_.*rb$/)
14
+ # end
15
+ #
16
+ # %w(TestA TestB).each do |klass|
17
+ # at.extra_class_map[klass] = "test/test_misc.rb"
18
+ # end
19
+ # end
20
+
21
+ # Autotest.add_hook :run_command do |at|
22
+ # system "rake build"
23
+ # end
File without changes
@@ -0,0 +1,6 @@
1
+ === 1.0.0 / 2013-05-22
2
+
3
+ * 1 major enhancement
4
+
5
+ * Birthday!
6
+
@@ -0,0 +1,10 @@
1
+ .autotest
2
+ .gemtest
3
+ History.txt
4
+ Manifest.txt
5
+ README.md
6
+ Rakefile
7
+ bin/stark_http
8
+ lib/stark/http.rb
9
+ stark-http.gemspec
10
+ test/test_stark_http.rb
@@ -0,0 +1,62 @@
1
+ # stark-http
2
+
3
+ * https://github.com/evanphx/stark-rack
4
+
5
+ ## DESCRIPTION:
6
+
7
+ HTTP Transport for Thrift services.
8
+
9
+ ![stark](http://ecx.images-amazon.com/images/I/41FuQ1aAkVL._SL500_AA300_.jpg)
10
+
11
+ ## FEATURES/PROBLEMS:
12
+
13
+ * Provides an easy HTTP transport for Thrift services so
14
+ deployment is easier than deploy socket based apps.
15
+ * Designed to work with [stark-rack](https://github.com/evanphx/stark-http)
16
+
17
+ ## SYNOPSIS:
18
+
19
+ FIX (code sample of usage)
20
+
21
+ ## REQUIREMENTS:
22
+
23
+ * [stark-rack](https://github.com/evanphx/stark-http) or alternative
24
+ and compatible endpoint.
25
+
26
+ ## INSTALL:
27
+
28
+ * gem install stark-http
29
+
30
+ ## DEVELOPERS:
31
+
32
+ After checking out the source, run:
33
+
34
+ $ rake newb
35
+
36
+ This task will install any missing dependencies, run the tests/specs,
37
+ and generate the RDoc.
38
+
39
+ ## LICENSE:
40
+
41
+ (The MIT License)
42
+
43
+ Copyright (c) 2013 Evan Phoenix
44
+
45
+ Permission is hereby granted, free of charge, to any person obtaining
46
+ a copy of this software and associated documentation files (the
47
+ 'Software'), to deal in the Software without restriction, including
48
+ without limitation the rights to use, copy, modify, merge, publish,
49
+ distribute, sublicense, and/or sell copies of the Software, and to
50
+ permit persons to whom the Software is furnished to do so, subject to
51
+ the following conditions:
52
+
53
+ The above copyright notice and this permission notice shall be
54
+ included in all copies or substantial portions of the Software.
55
+
56
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
57
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
58
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
59
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
60
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
61
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
62
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,14 @@
1
+ # -*- ruby -*-
2
+
3
+ require 'rubygems'
4
+ require 'hoe'
5
+
6
+ Hoe.plugin :gemspec
7
+
8
+ Hoe.spec 'stark-http' do
9
+ developer('Evan Phoenix', 'evan@phx.io')
10
+ dependency 'stark', '< 2.0.0'
11
+ readme_file = "README.md"
12
+ end
13
+
14
+ # vim: syntax=ruby
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'thrift/http'
4
+
5
+ file = ARGV.shift
6
+ klass = ARGV.shift
7
+
8
+ url = ARGV.shift
9
+
10
+ command = ARGV.shift
11
+
12
+ $:.unshift File.expand_path("..", file)
13
+ require file
14
+
15
+ int = eval "#{klass}::Client"
16
+
17
+ p url
18
+ p int
19
+ p command
20
+ p ARGV
21
+
22
+ args = eval "#{klass}::#{command.capitalize}_args"
23
+
24
+
25
+
26
+ client = Thrift::HTTP.open url, int
27
+
28
+ out = client.send command, *ARGV
29
+
30
+ p out
31
+
@@ -0,0 +1,64 @@
1
+ require 'stark'
2
+ require 'net/http'
3
+ require 'uri'
4
+ require 'thrift'
5
+
6
+ class Stark::HTTP
7
+ VERSION = '1.0.0'
8
+ HTTP_USER_AGENT = "#{self.name} #{VERSION} - Ruby #{RUBY_VERSION}"
9
+
10
+ class ClientTransport < Thrift::BaseTransport
11
+ def initialize(url)
12
+ @url = URI url
13
+ @headers = {'Content-Type' => 'application/x-thrift',
14
+ 'User-Agent' => Stark::HTTP::HTTP_USER_AGENT }
15
+ @outbuf = ""
16
+
17
+ @http = Net::HTTP.new @url.host, @url.port
18
+ @http.use_ssl = @url.scheme == "https"
19
+ if $DEBUG
20
+ @http.set_debug_output $stderr
21
+ end
22
+ end
23
+
24
+ def open?; true end
25
+ def read(sz); @inbuf.read sz end
26
+ def write(buf); @outbuf << buf end
27
+
28
+ def add_headers(headers)
29
+ @headers = @headers.merge(headers)
30
+ end
31
+
32
+ RETRY_ATTEMPTS = 10
33
+
34
+ def flush
35
+ attempts = 0
36
+
37
+ @http.start unless @http.started?
38
+
39
+ begin
40
+ resp = @http.post(@url.request_uri, @outbuf, @headers)
41
+ attempts = 0
42
+ rescue StandardError => e
43
+ @http.finish
44
+
45
+ raise e if attempts > RETRY_ATTEMPTS
46
+
47
+ attempts += 1
48
+
49
+ @http.start
50
+
51
+ retry
52
+ end
53
+
54
+ @inbuf = StringIO.new resp.body
55
+ @outbuf = ""
56
+ end
57
+ end
58
+
59
+ def self.open(url, interface)
60
+ trans = ClientTransport.new(url)
61
+ proto = Thrift::BinaryProtocolFactory.new.get_protocol trans
62
+ interface.new proto, proto
63
+ end
64
+ end
@@ -0,0 +1,40 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = "stark-http"
5
+ s.version = "1.0.0"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Evan Phoenix"]
9
+ s.date = "2013-05-22"
10
+ s.description = "HTTP Transport for Thrift services.\n\n![stark](http://ecx.images-amazon.com/images/I/41FuQ1aAkVL._SL500_AA300_.jpg)"
11
+ s.email = ["evan@phx.io"]
12
+ s.executables = ["stark_http"]
13
+ s.extra_rdoc_files = ["History.txt", "Manifest.txt", "README.md"]
14
+ s.files = [".autotest", ".gemtest", "History.txt", "Manifest.txt", "README.md", "Rakefile", "bin/stark_http", "lib/stark/http.rb", "stark-http.gemspec", "test/test_stark_http.rb"]
15
+ s.homepage = "https://github.com/evanphx/stark-rack"
16
+ s.rdoc_options = ["--main", "README.md"]
17
+ s.require_paths = ["lib"]
18
+ s.rubyforge_project = "stark-http"
19
+ s.rubygems_version = "1.8.23"
20
+ s.summary = "HTTP Transport for Thrift services"
21
+ s.test_files = ["test/test_stark_http.rb"]
22
+
23
+ if s.respond_to? :specification_version then
24
+ s.specification_version = 3
25
+
26
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
27
+ s.add_runtime_dependency(%q<stark>, ["< 2.0.0"])
28
+ s.add_development_dependency(%q<rdoc>, ["~> 4.0"])
29
+ s.add_development_dependency(%q<hoe>, ["~> 3.6"])
30
+ else
31
+ s.add_dependency(%q<stark>, ["< 2.0.0"])
32
+ s.add_dependency(%q<rdoc>, ["~> 4.0"])
33
+ s.add_dependency(%q<hoe>, ["~> 3.6"])
34
+ end
35
+ else
36
+ s.add_dependency(%q<stark>, ["< 2.0.0"])
37
+ s.add_dependency(%q<rdoc>, ["~> 4.0"])
38
+ s.add_dependency(%q<hoe>, ["~> 3.6"])
39
+ end
40
+ end
@@ -0,0 +1,8 @@
1
+ require "test/unit"
2
+ require "stark/http"
3
+
4
+ class TestStark::Http < Test::Unit::TestCase
5
+ def test_sanity
6
+ flunk "write tests or I will kneecap you"
7
+ end
8
+ end
metadata ADDED
@@ -0,0 +1,113 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: stark-http
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Evan Phoenix
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-05-22 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: stark
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - <
20
+ - !ruby/object:Gem::Version
21
+ version: 2.0.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - <
28
+ - !ruby/object:Gem::Version
29
+ version: 2.0.0
30
+ - !ruby/object:Gem::Dependency
31
+ name: rdoc
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '4.0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '4.0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: hoe
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: '3.6'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '3.6'
62
+ description: ! 'HTTP Transport for Thrift services.
63
+
64
+
65
+ ![stark](http://ecx.images-amazon.com/images/I/41FuQ1aAkVL._SL500_AA300_.jpg)'
66
+ email:
67
+ - evan@phx.io
68
+ executables:
69
+ - stark_http
70
+ extensions: []
71
+ extra_rdoc_files:
72
+ - History.txt
73
+ - Manifest.txt
74
+ - README.md
75
+ files:
76
+ - .autotest
77
+ - .gemtest
78
+ - History.txt
79
+ - Manifest.txt
80
+ - README.md
81
+ - Rakefile
82
+ - bin/stark_http
83
+ - lib/stark/http.rb
84
+ - stark-http.gemspec
85
+ - test/test_stark_http.rb
86
+ homepage: https://github.com/evanphx/stark-rack
87
+ licenses: []
88
+ post_install_message:
89
+ rdoc_options:
90
+ - --main
91
+ - README.md
92
+ require_paths:
93
+ - lib
94
+ required_ruby_version: !ruby/object:Gem::Requirement
95
+ none: false
96
+ requirements:
97
+ - - ! '>='
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ required_rubygems_version: !ruby/object:Gem::Requirement
101
+ none: false
102
+ requirements:
103
+ - - ! '>='
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
106
+ requirements: []
107
+ rubyforge_project: stark-http
108
+ rubygems_version: 1.8.23
109
+ signing_key:
110
+ specification_version: 3
111
+ summary: HTTP Transport for Thrift services
112
+ test_files:
113
+ - test/test_stark_http.rb