flying-sphinx 0.7.1 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY +4 -2
- data/README.textile +2 -2
- data/bin/flying-sphinx +5 -0
- data/flying-sphinx.gemspec +1 -3
- data/lib/flying_sphinx/cli.rb +67 -0
- data/lib/flying_sphinx/configuration.rb +2 -14
- data/lib/flying_sphinx/index_request.rb +5 -51
- data/lib/flying_sphinx/sphinx_configuration.rb +8 -3
- data/lib/flying_sphinx/tasks.rb +10 -17
- data/lib/flying_sphinx/version.rb +1 -1
- data/lib/flying_sphinx.rb +7 -4
- data/spec/light_spec_helper.rb +2 -0
- data/spec/specs/index_request_spec.rb +14 -88
- data/spec/specs/sphinx_configuration_spec.rb +1 -8
- metadata +60 -45
- data/lib/flying_sphinx/tunnel.rb +0 -59
data/HISTORY
CHANGED
@@ -1,5 +1,7 @@
|
|
1
|
-
0.
|
2
|
-
*
|
1
|
+
0.8.0 - 25th August 2012
|
2
|
+
* Making the executable the main command entry point.
|
3
|
+
* Adding a 'flying-sphinx' executable to match Python and Node.js clients.
|
4
|
+
* Removing support for accessing Heroku's shared databases through an SSH tunnel.
|
3
5
|
|
4
6
|
0.7.0 - 16th July 2012
|
5
7
|
* Print the indexing log.
|
data/README.textile
CHANGED
@@ -11,7 +11,7 @@ This is all covered pretty well on "the Flying Sphinx site":http://flying-sphinx
|
|
11
11
|
|
12
12
|
h2. Compatibility and Limitations
|
13
13
|
|
14
|
-
Flying Sphinx is built with support for Rails 2.3.6 and beyond. Sadly, earlier versions of Rails aren't supported due to a requirement of a recent version of Rack deep in the dependency tree.
|
14
|
+
Flying Sphinx is built with support for Rails 2.3.6 and beyond. Sadly, earlier versions of Rails aren't supported due to a requirement of a recent version of Rack deep in the dependency tree.
|
15
15
|
|
16
16
|
It works with Rails 1.8.7 and 1.9.2, and on both Heroku's Bamboo and Cedar stacks. You _do_ need to use it with Heroku at this point - allowing others hosting elsewhere to use Flying Sphinx is something I'm considering, but it's not possible right now.
|
17
17
|
|
@@ -36,4 +36,4 @@ h2. Contributors
|
|
36
36
|
|
37
37
|
h2. Licence
|
38
38
|
|
39
|
-
Copyright © 2011 Pat Allan, released under an MIT licence.
|
39
|
+
Copyright © 2011-2012 Pat Allan, released under an MIT licence.
|
data/bin/flying-sphinx
ADDED
data/flying-sphinx.gemspec
CHANGED
@@ -15,12 +15,10 @@ Gem::Specification.new do |s|
|
|
15
15
|
s.files = `git ls-files`.split("\n")
|
16
16
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
17
17
|
s.require_paths = ['lib']
|
18
|
-
|
19
|
-
s.rubygems_version = %q{1.3.7}
|
18
|
+
s.executables = ['flying-sphinx']
|
20
19
|
|
21
20
|
s.add_runtime_dependency 'thinking-sphinx', ['>= 0']
|
22
21
|
s.add_runtime_dependency 'riddle', ['>= 1.5.0']
|
23
|
-
s.add_runtime_dependency 'net-ssh', ['>= 2.0.23']
|
24
22
|
s.add_runtime_dependency 'multi_json', ['>= 1.0.1']
|
25
23
|
s.add_runtime_dependency 'faraday_middleware', ['~> 0.7']
|
26
24
|
s.add_runtime_dependency 'rash', ['~> 0.3.0']
|
@@ -0,0 +1,67 @@
|
|
1
|
+
class FlyingSphinx::CLI
|
2
|
+
COMMANDS = {
|
3
|
+
'configure' => [:configure],
|
4
|
+
'index' => [:index],
|
5
|
+
'setup' => [:configure, :index],
|
6
|
+
'start' => [:start],
|
7
|
+
'stop' => [:stop],
|
8
|
+
'restart' => [:stop, :start],
|
9
|
+
'rebuild' => [:stop, :index, :start]
|
10
|
+
}
|
11
|
+
|
12
|
+
def initialize(command, arguments = [])
|
13
|
+
@command, @arguments = command, arguments
|
14
|
+
end
|
15
|
+
|
16
|
+
def run
|
17
|
+
methods = COMMANDS[@command]
|
18
|
+
raise "Unknown command #{@command}" if methods.nil?
|
19
|
+
|
20
|
+
methods.all? { |method| send method }
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def configuration
|
26
|
+
@configuration ||= FlyingSphinx::Configuration.new
|
27
|
+
end
|
28
|
+
|
29
|
+
def configure
|
30
|
+
if @arguments.empty?
|
31
|
+
FlyingSphinx::SphinxConfiguration.new.upload_to configuration.api
|
32
|
+
FlyingSphinx::SettingFiles.new.upload_to configuration.api
|
33
|
+
else
|
34
|
+
FlyingSphinx::SphinxConfiguration.new.upload_file_to configuration.api,
|
35
|
+
@arguments.first
|
36
|
+
end
|
37
|
+
|
38
|
+
puts "Sent configuration to Sphinx"
|
39
|
+
true
|
40
|
+
end
|
41
|
+
|
42
|
+
def index
|
43
|
+
FlyingSphinx::IndexRequest.cancel_jobs
|
44
|
+
|
45
|
+
request = FlyingSphinx::IndexRequest.new @arguments
|
46
|
+
request.index
|
47
|
+
puts request.status_message
|
48
|
+
|
49
|
+
true
|
50
|
+
end
|
51
|
+
|
52
|
+
def start
|
53
|
+
if configuration.start_sphinx
|
54
|
+
puts "Started Sphinx"
|
55
|
+
true
|
56
|
+
else
|
57
|
+
puts "Sphinx failed to start... have you indexed first?"
|
58
|
+
false
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def stop
|
63
|
+
configuration.stop_sphinx
|
64
|
+
puts "Stopped Sphinx"
|
65
|
+
true
|
66
|
+
end
|
67
|
+
end
|
@@ -13,11 +13,11 @@ class FlyingSphinx::Configuration
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def start_sphinx
|
16
|
-
|
16
|
+
api.post('start').success?
|
17
17
|
end
|
18
18
|
|
19
19
|
def stop_sphinx
|
20
|
-
|
20
|
+
api.post('stop').success?
|
21
21
|
end
|
22
22
|
|
23
23
|
def client_key
|
@@ -33,18 +33,6 @@ class FlyingSphinx::Configuration
|
|
33
33
|
private
|
34
34
|
|
35
35
|
attr_reader :identifier, :api_key
|
36
|
-
|
37
|
-
def change(initial, expected)
|
38
|
-
api.post(initial)
|
39
|
-
|
40
|
-
response = api.get('daemon')
|
41
|
-
while response.body.status == initial
|
42
|
-
sleep 0.5
|
43
|
-
response = api.get('daemon')
|
44
|
-
end
|
45
|
-
|
46
|
-
response.body.status == expected
|
47
|
-
end
|
48
36
|
|
49
37
|
def set_from_server
|
50
38
|
response = api.get '/'
|
@@ -28,11 +28,11 @@ class FlyingSphinx::IndexRequest
|
|
28
28
|
"#{self.class.name} for #{indices.join(', ')}"
|
29
29
|
end
|
30
30
|
|
31
|
-
def
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
31
|
+
def index
|
32
|
+
begin_request
|
33
|
+
while !request_complete?
|
34
|
+
sleep 3
|
35
|
+
end
|
36
36
|
end
|
37
37
|
|
38
38
|
def status_message
|
@@ -67,35 +67,6 @@ class FlyingSphinx::IndexRequest
|
|
67
67
|
@configuration ||= FlyingSphinx::Configuration.new
|
68
68
|
end
|
69
69
|
|
70
|
-
def index
|
71
|
-
if tunnel?
|
72
|
-
tunnelled_index
|
73
|
-
else
|
74
|
-
direct_index
|
75
|
-
end
|
76
|
-
rescue Net::SSH::Exception => err
|
77
|
-
# Server closed the connection on us. That's (hopefully) expected, nothing
|
78
|
-
# to worry about.
|
79
|
-
puts "SSH/Indexing Error: #{err.message}" if log?
|
80
|
-
rescue RuntimeError => err
|
81
|
-
puts err.message
|
82
|
-
end
|
83
|
-
|
84
|
-
def tunnelled_index
|
85
|
-
FlyingSphinx::Tunnel.connect(configuration) do
|
86
|
-
begin_request unless request_begun?
|
87
|
-
|
88
|
-
true
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
def direct_index
|
93
|
-
begin_request
|
94
|
-
while !request_complete?
|
95
|
-
sleep 3
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
70
|
def begin_request
|
100
71
|
response = api.post 'indices', :indices => indices.join(',')
|
101
72
|
|
@@ -129,24 +100,7 @@ class FlyingSphinx::IndexRequest
|
|
129
100
|
@request.status
|
130
101
|
end
|
131
102
|
|
132
|
-
def tunnel?
|
133
|
-
FlyingSphinx::Tunnel.required?
|
134
|
-
end
|
135
|
-
|
136
|
-
def cancel_request
|
137
|
-
return if index_id.nil?
|
138
|
-
|
139
|
-
puts "Connecting Flying Sphinx to the Database failed"
|
140
|
-
puts "Cancelling Index Request..."
|
141
|
-
|
142
|
-
api.put("indices/#{index_id}", :status => 'CANCELLED')
|
143
|
-
end
|
144
|
-
|
145
103
|
def api
|
146
104
|
configuration.api
|
147
105
|
end
|
148
|
-
|
149
|
-
def log?
|
150
|
-
ENV['VERBOSE_LOGGING'] && ENV['VERBOSE_LOGGING'].length > 0
|
151
|
-
end
|
152
106
|
end
|
@@ -3,11 +3,16 @@ class FlyingSphinx::SphinxConfiguration
|
|
3
3
|
@thinking_sphinx = thinking_sphinx
|
4
4
|
end
|
5
5
|
|
6
|
-
def upload_to(api
|
6
|
+
def upload_to(api)
|
7
7
|
api.put '/',
|
8
8
|
:configuration => content,
|
9
|
-
:sphinx_version => thinking_sphinx.version
|
10
|
-
|
9
|
+
:sphinx_version => thinking_sphinx.version
|
10
|
+
end
|
11
|
+
|
12
|
+
def upload_file_to(api, path)
|
13
|
+
api.put '/',
|
14
|
+
:configuration => File.read(path),
|
15
|
+
:sphinx_version => '2.0.4'
|
11
16
|
end
|
12
17
|
|
13
18
|
private
|
data/lib/flying_sphinx/tasks.rb
CHANGED
@@ -1,30 +1,23 @@
|
|
1
1
|
namespace :fs do
|
2
2
|
task :index => :environment do
|
3
|
-
|
4
|
-
FlyingSphinx::IndexRequest.cancel_jobs
|
5
|
-
request = FlyingSphinx::IndexRequest.new
|
6
|
-
request.update_and_index
|
7
|
-
puts request.status_message
|
3
|
+
FlyingSphinx::CLI.new('setup').run
|
8
4
|
end
|
9
5
|
|
10
6
|
task :start => :environment do
|
11
|
-
|
12
|
-
|
13
|
-
if FlyingSphinx::Configuration.new.start_sphinx
|
14
|
-
puts "Started Sphinx"
|
15
|
-
else
|
16
|
-
puts "Sphinx failed to start... have you indexed first?"
|
17
|
-
end
|
7
|
+
FlyingSphinx::CLI.new('start').run
|
18
8
|
end
|
19
9
|
|
20
10
|
task :stop => :environment do
|
21
|
-
|
22
|
-
|
23
|
-
|
11
|
+
FlyingSphinx::CLI.new('stop').run
|
12
|
+
end
|
13
|
+
|
14
|
+
task :restart => :environment do
|
15
|
+
FlyingSphinx::CLI.new('restart').run
|
24
16
|
end
|
25
17
|
|
26
|
-
task :
|
27
|
-
|
18
|
+
task :rebuild => :environment do
|
19
|
+
FlyingSphinx::CLI.new('rebuild').run
|
20
|
+
end
|
28
21
|
|
29
22
|
task :index_log => :environment do
|
30
23
|
FlyingSphinx::IndexRequest.output_last_index
|
data/lib/flying_sphinx.rb
CHANGED
@@ -4,20 +4,23 @@ end
|
|
4
4
|
|
5
5
|
require 'faraday'
|
6
6
|
require 'faraday_middleware'
|
7
|
-
require '
|
7
|
+
require 'riddle'
|
8
8
|
require 'riddle/0.9.9'
|
9
9
|
|
10
10
|
require 'flying_sphinx/api'
|
11
|
+
require 'flying_sphinx/cli'
|
11
12
|
require 'flying_sphinx/configuration'
|
12
|
-
require 'flying_sphinx/delayed_delta'
|
13
13
|
require 'flying_sphinx/flag_as_deleted_job'
|
14
|
-
require 'flying_sphinx/heroku_shared_adapter'
|
15
14
|
require 'flying_sphinx/index_request'
|
16
15
|
require 'flying_sphinx/setting_files'
|
17
16
|
require 'flying_sphinx/sphinx_configuration'
|
18
|
-
require 'flying_sphinx/tunnel'
|
19
17
|
require 'flying_sphinx/version'
|
20
18
|
|
19
|
+
if defined?(ThinkingSphinx)
|
20
|
+
require 'flying_sphinx/delayed_delta'
|
21
|
+
require 'flying_sphinx/heroku_shared_adapter'
|
22
|
+
end
|
23
|
+
|
21
24
|
if defined?(Rails) && defined?(Rails::Railtie)
|
22
25
|
require 'flying_sphinx/railtie'
|
23
26
|
elsif defined?(Rails)
|
data/spec/light_spec_helper.rb
CHANGED
@@ -1,13 +1,10 @@
|
|
1
1
|
require 'light_spec_helper'
|
2
|
-
require 'net/ssh/errors'
|
3
2
|
require 'timeout'
|
4
3
|
require 'flying_sphinx/index_request'
|
5
4
|
|
6
5
|
describe FlyingSphinx::IndexRequest do
|
7
6
|
let(:api) { fire_double('FlyingSphinx::API') }
|
8
7
|
let(:configuration) { stub(:configuration, :api => api) }
|
9
|
-
let(:tunnel_class) { fire_class_double('FlyingSphinx::Tunnel').
|
10
|
-
as_replaced_constant }
|
11
8
|
|
12
9
|
let(:index_response) {
|
13
10
|
stub(:response, :body => stub(:body, :id => 42, :status => 'OK'))
|
@@ -18,7 +15,6 @@ describe FlyingSphinx::IndexRequest do
|
|
18
15
|
|
19
16
|
before :each do
|
20
17
|
stub_const 'FlyingSphinx::Configuration', double(:new => configuration)
|
21
|
-
|
22
18
|
stub_const 'FlyingSphinx::IndexRequest::INDEX_COMPLETE_CHECKING_INTERVAL',
|
23
19
|
0
|
24
20
|
end
|
@@ -57,107 +53,37 @@ describe FlyingSphinx::IndexRequest do
|
|
57
53
|
end
|
58
54
|
end
|
59
55
|
|
60
|
-
describe '#
|
56
|
+
describe '#index' do
|
61
57
|
let(:index_request) { FlyingSphinx::IndexRequest.new }
|
62
|
-
let(:conf_params) { { :configuration => 'foo {}',
|
63
|
-
:sphinx_version => '2.1.0-dev' } }
|
64
58
|
let(:index_params) { { :indices => '' } }
|
65
|
-
let(:
|
66
|
-
:
|
67
|
-
let(:setting_files) { fire_double('FlyingSphinx::SettingFiles',
|
68
|
-
:upload_to => true) }
|
59
|
+
let(:status_response) { stub(:response,
|
60
|
+
:body => stub(:body, :status => 'FINISHED')) }
|
69
61
|
|
70
62
|
before :each do
|
71
|
-
|
72
|
-
stub_const 'FlyingSphinx::SphinxConfiguration', double(:new => sphinx)
|
73
|
-
|
74
|
-
api.stub :post => index_response
|
75
|
-
|
76
|
-
tunnel_class.stub :required? => true
|
77
|
-
tunnel_class.stub(:connect).and_yield
|
78
|
-
end
|
79
|
-
|
80
|
-
it "uploads the configuration file" do
|
81
|
-
sphinx.should_receive(:upload_to).with(api, true)
|
82
|
-
|
83
|
-
begin
|
84
|
-
Timeout::timeout(0.2) {
|
85
|
-
index_request.update_and_index
|
86
|
-
}
|
87
|
-
rescue Timeout::Error
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
it "uploads setting files" do
|
92
|
-
setting_files.should_receive(:upload_to).with(api)
|
93
|
-
|
94
|
-
begin
|
95
|
-
Timeout::timeout(0.2) {
|
96
|
-
index_request.update_and_index
|
97
|
-
}
|
98
|
-
rescue Timeout::Error
|
99
|
-
end
|
63
|
+
api.stub :post => index_response, :get => status_response
|
100
64
|
end
|
101
65
|
|
102
66
|
it "makes a new request" do
|
103
67
|
api.should_receive(:post).
|
104
68
|
with('indices', index_params).and_return(index_response)
|
105
69
|
|
106
|
-
|
107
|
-
Timeout::timeout(0.2) {
|
108
|
-
index_request.update_and_index
|
109
|
-
}
|
110
|
-
rescue Timeout::Error
|
111
|
-
end
|
70
|
+
index_request.index
|
112
71
|
end
|
113
72
|
|
114
|
-
|
115
|
-
|
116
|
-
api.should_receive(:post).
|
117
|
-
with('indices', index_params).and_return(blocked_response)
|
118
|
-
index_request.should_receive(:puts).
|
119
|
-
with('Your account does not support delta indexing. Upgrading plans is probably the best way around this.')
|
73
|
+
it "checks the status of the request" do
|
74
|
+
api.should_receive(:get).with('indices/42').and_return(status_response)
|
120
75
|
|
121
|
-
|
122
|
-
end
|
76
|
+
index_request.index
|
123
77
|
end
|
124
78
|
|
125
|
-
context 'request
|
126
|
-
|
127
|
-
tunnel_class.stub :required? => false
|
128
|
-
end
|
129
|
-
|
130
|
-
it "should not establish an SSH connection" do
|
131
|
-
FlyingSphinx::Tunnel.should_not_receive(:connect)
|
132
|
-
|
79
|
+
context 'delta request without delta support' do
|
80
|
+
it "should explain why the request failed" do
|
133
81
|
api.should_receive(:post).
|
134
|
-
with('indices', index_params).and_return(
|
135
|
-
api.should_receive(:get).with('indices/42').
|
136
|
-
and_return(stub(:response, :body => stub(:body, :status => 'FINISHED')))
|
137
|
-
|
138
|
-
index_request.update_and_index
|
139
|
-
end
|
140
|
-
end
|
141
|
-
end
|
142
|
-
|
143
|
-
describe '#perform' do
|
144
|
-
let(:index_request) { FlyingSphinx::IndexRequest.new ['foo_delta'] }
|
145
|
-
let(:index_params) { { :indices => 'foo_delta' } }
|
146
|
-
|
147
|
-
before :each do
|
148
|
-
tunnel_class.stub :required? => true
|
149
|
-
tunnel_class.stub(:connect).and_yield
|
150
|
-
end
|
151
|
-
|
152
|
-
it "makes a new request" do
|
153
|
-
api.should_receive(:post).
|
154
|
-
with('indices', index_params).and_return(index_response)
|
82
|
+
with('indices', index_params).and_return(blocked_response)
|
155
83
|
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
}
|
160
|
-
rescue Timeout::Error
|
84
|
+
lambda {
|
85
|
+
index_request.index
|
86
|
+
}.should raise_error(RuntimeError, 'Your account does not support delta indexing. Upgrading plans is probably the best way around this.')
|
161
87
|
end
|
162
88
|
end
|
163
89
|
end
|
@@ -20,16 +20,9 @@ describe FlyingSphinx::SphinxConfiguration do
|
|
20
20
|
|
21
21
|
it "sends the configuration to the API" do
|
22
22
|
api.should_receive(:put).with('/', :configuration => 'foo {}',
|
23
|
-
:sphinx_version => '2.1.0-dev'
|
23
|
+
:sphinx_version => '2.1.0-dev')
|
24
24
|
|
25
25
|
configuration.upload_to api
|
26
26
|
end
|
27
|
-
|
28
|
-
it "informs the API when tunnelling will be required" do
|
29
|
-
api.should_receive(:put).with('/', :configuration => 'foo {}',
|
30
|
-
:sphinx_version => '2.1.0-dev', :tunnel => 'true')
|
31
|
-
|
32
|
-
configuration.upload_to api, true
|
33
|
-
end
|
34
27
|
end
|
35
28
|
end
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flying-sphinx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 63
|
5
|
+
prerelease:
|
5
6
|
segments:
|
6
7
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 0.
|
8
|
+
- 8
|
9
|
+
- 0
|
10
|
+
version: 0.8.0
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Pat Allan
|
@@ -14,16 +15,17 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2012-
|
18
|
-
default_executable:
|
18
|
+
date: 2012-08-25 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: thinking-sphinx
|
22
22
|
prerelease: false
|
23
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
24
25
|
requirements:
|
25
26
|
- - ">="
|
26
27
|
- !ruby/object:Gem::Version
|
28
|
+
hash: 3
|
27
29
|
segments:
|
28
30
|
- 0
|
29
31
|
version: "0"
|
@@ -33,9 +35,11 @@ dependencies:
|
|
33
35
|
name: riddle
|
34
36
|
prerelease: false
|
35
37
|
requirement: &id002 !ruby/object:Gem::Requirement
|
38
|
+
none: false
|
36
39
|
requirements:
|
37
40
|
- - ">="
|
38
41
|
- !ruby/object:Gem::Version
|
42
|
+
hash: 3
|
39
43
|
segments:
|
40
44
|
- 1
|
41
45
|
- 5
|
@@ -43,162 +47,168 @@ dependencies:
|
|
43
47
|
version: 1.5.0
|
44
48
|
type: :runtime
|
45
49
|
version_requirements: *id002
|
46
|
-
- !ruby/object:Gem::Dependency
|
47
|
-
name: net-ssh
|
48
|
-
prerelease: false
|
49
|
-
requirement: &id003 !ruby/object:Gem::Requirement
|
50
|
-
requirements:
|
51
|
-
- - ">="
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
segments:
|
54
|
-
- 2
|
55
|
-
- 0
|
56
|
-
- 23
|
57
|
-
version: 2.0.23
|
58
|
-
type: :runtime
|
59
|
-
version_requirements: *id003
|
60
50
|
- !ruby/object:Gem::Dependency
|
61
51
|
name: multi_json
|
62
52
|
prerelease: false
|
63
|
-
requirement: &
|
53
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
64
55
|
requirements:
|
65
56
|
- - ">="
|
66
57
|
- !ruby/object:Gem::Version
|
58
|
+
hash: 21
|
67
59
|
segments:
|
68
60
|
- 1
|
69
61
|
- 0
|
70
62
|
- 1
|
71
63
|
version: 1.0.1
|
72
64
|
type: :runtime
|
73
|
-
version_requirements: *
|
65
|
+
version_requirements: *id003
|
74
66
|
- !ruby/object:Gem::Dependency
|
75
67
|
name: faraday_middleware
|
76
68
|
prerelease: false
|
77
|
-
requirement: &
|
69
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
70
|
+
none: false
|
78
71
|
requirements:
|
79
72
|
- - ~>
|
80
73
|
- !ruby/object:Gem::Version
|
74
|
+
hash: 5
|
81
75
|
segments:
|
82
76
|
- 0
|
83
77
|
- 7
|
84
78
|
version: "0.7"
|
85
79
|
type: :runtime
|
86
|
-
version_requirements: *
|
80
|
+
version_requirements: *id004
|
87
81
|
- !ruby/object:Gem::Dependency
|
88
82
|
name: rash
|
89
83
|
prerelease: false
|
90
|
-
requirement: &
|
84
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
85
|
+
none: false
|
91
86
|
requirements:
|
92
87
|
- - ~>
|
93
88
|
- !ruby/object:Gem::Version
|
89
|
+
hash: 19
|
94
90
|
segments:
|
95
91
|
- 0
|
96
92
|
- 3
|
97
93
|
- 0
|
98
94
|
version: 0.3.0
|
99
95
|
type: :runtime
|
100
|
-
version_requirements: *
|
96
|
+
version_requirements: *id005
|
101
97
|
- !ruby/object:Gem::Dependency
|
102
98
|
name: rake
|
103
99
|
prerelease: false
|
104
|
-
requirement: &
|
100
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
101
|
+
none: false
|
105
102
|
requirements:
|
106
103
|
- - ~>
|
107
104
|
- !ruby/object:Gem::Version
|
105
|
+
hash: 63
|
108
106
|
segments:
|
109
107
|
- 0
|
110
108
|
- 9
|
111
109
|
- 2
|
112
110
|
version: 0.9.2
|
113
111
|
type: :development
|
114
|
-
version_requirements: *
|
112
|
+
version_requirements: *id006
|
115
113
|
- !ruby/object:Gem::Dependency
|
116
114
|
name: rspec
|
117
115
|
prerelease: false
|
118
|
-
requirement: &
|
116
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
117
|
+
none: false
|
119
118
|
requirements:
|
120
119
|
- - ~>
|
121
120
|
- !ruby/object:Gem::Version
|
121
|
+
hash: 21
|
122
122
|
segments:
|
123
123
|
- 2
|
124
124
|
- 11
|
125
125
|
version: "2.11"
|
126
126
|
type: :development
|
127
|
-
version_requirements: *
|
127
|
+
version_requirements: *id007
|
128
128
|
- !ruby/object:Gem::Dependency
|
129
129
|
name: rspec-fire
|
130
130
|
prerelease: false
|
131
|
-
requirement: &
|
131
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
132
|
+
none: false
|
132
133
|
requirements:
|
133
134
|
- - ~>
|
134
135
|
- !ruby/object:Gem::Version
|
136
|
+
hash: 19
|
135
137
|
segments:
|
136
138
|
- 1
|
137
139
|
- 1
|
138
140
|
- 0
|
139
141
|
version: 1.1.0
|
140
142
|
type: :development
|
141
|
-
version_requirements: *
|
143
|
+
version_requirements: *id008
|
142
144
|
- !ruby/object:Gem::Dependency
|
143
145
|
name: yajl-ruby
|
144
146
|
prerelease: false
|
145
|
-
requirement: &
|
147
|
+
requirement: &id009 !ruby/object:Gem::Requirement
|
148
|
+
none: false
|
146
149
|
requirements:
|
147
150
|
- - ~>
|
148
151
|
- !ruby/object:Gem::Version
|
152
|
+
hash: 59
|
149
153
|
segments:
|
150
154
|
- 0
|
151
155
|
- 8
|
152
156
|
- 2
|
153
157
|
version: 0.8.2
|
154
158
|
type: :development
|
155
|
-
version_requirements: *
|
159
|
+
version_requirements: *id009
|
156
160
|
- !ruby/object:Gem::Dependency
|
157
161
|
name: fakeweb
|
158
162
|
prerelease: false
|
159
|
-
requirement: &
|
163
|
+
requirement: &id010 !ruby/object:Gem::Requirement
|
164
|
+
none: false
|
160
165
|
requirements:
|
161
166
|
- - ~>
|
162
167
|
- !ruby/object:Gem::Version
|
168
|
+
hash: 27
|
163
169
|
segments:
|
164
170
|
- 1
|
165
171
|
- 3
|
166
172
|
- 0
|
167
173
|
version: 1.3.0
|
168
174
|
type: :development
|
169
|
-
version_requirements: *
|
175
|
+
version_requirements: *id010
|
170
176
|
- !ruby/object:Gem::Dependency
|
171
177
|
name: fakeweb-matcher
|
172
178
|
prerelease: false
|
173
|
-
requirement: &
|
179
|
+
requirement: &id011 !ruby/object:Gem::Requirement
|
180
|
+
none: false
|
174
181
|
requirements:
|
175
182
|
- - ~>
|
176
183
|
- !ruby/object:Gem::Version
|
184
|
+
hash: 27
|
177
185
|
segments:
|
178
186
|
- 1
|
179
187
|
- 2
|
180
188
|
- 2
|
181
189
|
version: 1.2.2
|
182
190
|
type: :development
|
183
|
-
version_requirements: *
|
191
|
+
version_requirements: *id011
|
184
192
|
- !ruby/object:Gem::Dependency
|
185
193
|
name: delayed_job
|
186
194
|
prerelease: false
|
187
|
-
requirement: &
|
195
|
+
requirement: &id012 !ruby/object:Gem::Requirement
|
196
|
+
none: false
|
188
197
|
requirements:
|
189
198
|
- - ~>
|
190
199
|
- !ruby/object:Gem::Version
|
200
|
+
hash: 3
|
191
201
|
segments:
|
192
202
|
- 2
|
193
203
|
- 1
|
194
204
|
- 4
|
195
205
|
version: 2.1.4
|
196
206
|
type: :development
|
197
|
-
version_requirements: *
|
207
|
+
version_requirements: *id012
|
198
208
|
description: Hooks Thinking Sphinx into the Flying Sphinx service
|
199
209
|
email: pat@freelancing-gods.com
|
200
|
-
executables:
|
201
|
-
|
210
|
+
executables:
|
211
|
+
- flying-sphinx
|
202
212
|
extensions: []
|
203
213
|
|
204
214
|
extra_rdoc_files:
|
@@ -211,11 +221,13 @@ files:
|
|
211
221
|
- LICENCE
|
212
222
|
- README.textile
|
213
223
|
- Rakefile
|
224
|
+
- bin/flying-sphinx
|
214
225
|
- flying-sphinx.gemspec
|
215
226
|
- keys/key
|
216
227
|
- lib/flying-sphinx.rb
|
217
228
|
- lib/flying_sphinx.rb
|
218
229
|
- lib/flying_sphinx/api.rb
|
230
|
+
- lib/flying_sphinx/cli.rb
|
219
231
|
- lib/flying_sphinx/configuration.rb
|
220
232
|
- lib/flying_sphinx/delayed_delta.rb
|
221
233
|
- lib/flying_sphinx/flag_as_deleted_job.rb
|
@@ -227,7 +239,6 @@ files:
|
|
227
239
|
- lib/flying_sphinx/sinatra.rb
|
228
240
|
- lib/flying_sphinx/sphinx_configuration.rb
|
229
241
|
- lib/flying_sphinx/tasks.rb
|
230
|
-
- lib/flying_sphinx/tunnel.rb
|
231
242
|
- lib/flying_sphinx/version.rb
|
232
243
|
- spec/light_spec_helper.rb
|
233
244
|
- spec/spec_helper.rb
|
@@ -238,7 +249,6 @@ files:
|
|
238
249
|
- spec/specs/index_request_spec.rb
|
239
250
|
- spec/specs/setting_files_spec.rb
|
240
251
|
- spec/specs/sphinx_configuration_spec.rb
|
241
|
-
has_rdoc: true
|
242
252
|
homepage: https://flying-sphinx.com
|
243
253
|
licenses: []
|
244
254
|
|
@@ -252,23 +262,27 @@ rdoc_options: []
|
|
252
262
|
require_paths:
|
253
263
|
- lib
|
254
264
|
required_ruby_version: !ruby/object:Gem::Requirement
|
265
|
+
none: false
|
255
266
|
requirements:
|
256
267
|
- - ">="
|
257
268
|
- !ruby/object:Gem::Version
|
269
|
+
hash: 3
|
258
270
|
segments:
|
259
271
|
- 0
|
260
272
|
version: "0"
|
261
273
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
274
|
+
none: false
|
262
275
|
requirements:
|
263
276
|
- - ">="
|
264
277
|
- !ruby/object:Gem::Version
|
278
|
+
hash: 3
|
265
279
|
segments:
|
266
280
|
- 0
|
267
281
|
version: "0"
|
268
282
|
requirements: []
|
269
283
|
|
270
284
|
rubyforge_project:
|
271
|
-
rubygems_version: 1.
|
285
|
+
rubygems_version: 1.8.16
|
272
286
|
signing_key:
|
273
287
|
specification_version: 3
|
274
288
|
summary: Sphinx in the Cloud
|
@@ -282,3 +296,4 @@ test_files:
|
|
282
296
|
- spec/specs/index_request_spec.rb
|
283
297
|
- spec/specs/setting_files_spec.rb
|
284
298
|
- spec/specs/sphinx_configuration_spec.rb
|
299
|
+
has_rdoc:
|
data/lib/flying_sphinx/tunnel.rb
DELETED
@@ -1,59 +0,0 @@
|
|
1
|
-
class FlyingSphinx::Tunnel
|
2
|
-
def self.connect(configuration, &block)
|
3
|
-
tunnel = new configuration
|
4
|
-
tunnel.open do |session|
|
5
|
-
session.loop do
|
6
|
-
block.call
|
7
|
-
end
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
def self.required?
|
12
|
-
ENV['FLYING_SPHINX_INGRESS'].blank? &&
|
13
|
-
ThinkingSphinx.database_adapter == FlyingSphinx::HerokuSharedAdapter
|
14
|
-
end
|
15
|
-
|
16
|
-
def initialize(configuration)
|
17
|
-
@configuration = configuration
|
18
|
-
end
|
19
|
-
|
20
|
-
def open(&block)
|
21
|
-
session = Net::SSH.start(@configuration.ssh_server, 'sphinx', ssh_options)
|
22
|
-
session.forward.remote(
|
23
|
-
db_port, db_host, @configuration.database_port, '0.0.0.0'
|
24
|
-
)
|
25
|
-
|
26
|
-
session.loop { !remote_exists?(session) }
|
27
|
-
|
28
|
-
yield session
|
29
|
-
rescue IOError
|
30
|
-
# Server closed the connection on us. That's (hopefully) expected, nothing
|
31
|
-
# to worry about.
|
32
|
-
end
|
33
|
-
|
34
|
-
private
|
35
|
-
|
36
|
-
def db_host
|
37
|
-
db_config[:host]
|
38
|
-
end
|
39
|
-
|
40
|
-
def db_port
|
41
|
-
db_config[:port] || 5432
|
42
|
-
end
|
43
|
-
|
44
|
-
def db_config
|
45
|
-
@db_config ||= ActiveRecord::Base.connection.instance_variable_get(:@config)
|
46
|
-
end
|
47
|
-
|
48
|
-
def ssh_options
|
49
|
-
{:keys => [
|
50
|
-
File.expand_path('../../../keys/key', __FILE__)
|
51
|
-
]}
|
52
|
-
end
|
53
|
-
|
54
|
-
def remote_exists?(session)
|
55
|
-
session.forward.active_remotes.include?(
|
56
|
-
[@configuration.database_port, '0.0.0.0']
|
57
|
-
)
|
58
|
-
end
|
59
|
-
end
|