promiscuous 0.50.0 → 0.50.1
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.
- data/bin/promiscuous +1 -1
- data/lib/promiscuous/cli.rb +29 -23
- data/lib/promiscuous/subscriber/worker/message.rb +1 -0
- data/lib/promiscuous/version.rb +1 -1
- metadata +2 -2
data/bin/promiscuous
CHANGED
data/lib/promiscuous/cli.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
class Promiscuous::CLI
|
2
|
+
attr_accessor :options
|
3
|
+
|
2
4
|
def self.trap_signals
|
3
5
|
Signal.trap 'SIGUSR2' do
|
4
6
|
Thread.list.each do |thread|
|
@@ -14,18 +16,19 @@ class Promiscuous::CLI
|
|
14
16
|
end
|
15
17
|
trap_signals
|
16
18
|
|
17
|
-
def publish
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
19
|
+
def publish
|
20
|
+
options[:criterias].map { |criteria| eval(criteria) }.each do |criteria|
|
21
|
+
title = criteria.name
|
22
|
+
title = "#{title}#{' ' * [0, 20 - title.size].max}"
|
23
|
+
bar = ProgressBar.create(:format => '%t |%b>%i| %c/%C %e', :title => title, :total => criteria.count)
|
24
|
+
criteria.each do |doc|
|
25
|
+
doc.promiscuous_sync
|
26
|
+
bar.increment
|
27
|
+
end
|
25
28
|
end
|
26
29
|
end
|
27
30
|
|
28
|
-
def subscribe
|
31
|
+
def subscribe
|
29
32
|
Promiscuous::Loader.load_descriptors if defined?(Rails)
|
30
33
|
print_status "Replicating with #{Promiscuous::Subscriber::AMQP.subscribers.count} subscribers"
|
31
34
|
Promiscuous::Subscriber::Worker.run
|
@@ -42,8 +45,8 @@ class Promiscuous::CLI
|
|
42
45
|
|
43
46
|
opts.separator ""
|
44
47
|
opts.separator "Actions:"
|
45
|
-
opts.separator " publish \"
|
46
|
-
opts.separator " subscribe"
|
48
|
+
opts.separator " promiscuous publish \"Member.where(:updated_at.gt => 1.day.ago)\" BrandAction"
|
49
|
+
opts.separator " promiscuous subscribe"
|
47
50
|
opts.separator ""
|
48
51
|
opts.separator "Options:"
|
49
52
|
|
@@ -71,7 +74,7 @@ class Promiscuous::CLI
|
|
71
74
|
parser.parse!(args)
|
72
75
|
|
73
76
|
options[:action] = args.shift.try(:to_sym)
|
74
|
-
options[:
|
77
|
+
options[:criterias] = args
|
75
78
|
|
76
79
|
unless options[:action].in? [:publish, :subscribe]
|
77
80
|
puts parser
|
@@ -79,9 +82,9 @@ class Promiscuous::CLI
|
|
79
82
|
end
|
80
83
|
|
81
84
|
if options[:action] == :publish
|
82
|
-
raise "Please specify
|
85
|
+
raise "Please specify one or more criterias" unless options[:criterias].present?
|
83
86
|
else
|
84
|
-
raise "Why are you specifying a criteria?" if options[:
|
87
|
+
raise "Why are you specifying a criteria?" if options[:criterias].present?
|
85
88
|
end
|
86
89
|
|
87
90
|
options
|
@@ -90,7 +93,7 @@ class Promiscuous::CLI
|
|
90
93
|
exit
|
91
94
|
end
|
92
95
|
|
93
|
-
def load_app
|
96
|
+
def load_app
|
94
97
|
if options[:require]
|
95
98
|
require options[:require]
|
96
99
|
else
|
@@ -100,22 +103,25 @@ class Promiscuous::CLI
|
|
100
103
|
end
|
101
104
|
end
|
102
105
|
|
103
|
-
def
|
104
|
-
options = parse_args(ARGV)
|
105
|
-
load_app
|
106
|
-
maybe_run_bareback
|
106
|
+
def boot
|
107
|
+
self.options = parse_args(ARGV)
|
108
|
+
load_app
|
109
|
+
maybe_run_bareback
|
110
|
+
run
|
111
|
+
end
|
107
112
|
|
113
|
+
def run
|
108
114
|
case options[:action]
|
109
|
-
when :publish then publish
|
110
|
-
when :subscribe then subscribe
|
115
|
+
when :publish then publish
|
116
|
+
when :subscribe then subscribe
|
111
117
|
end
|
112
118
|
end
|
113
119
|
|
114
|
-
def maybe_run_bareback
|
120
|
+
def maybe_run_bareback
|
115
121
|
if options[:bareback]
|
116
122
|
Promiscuous::Config.bareback = true
|
117
123
|
print_status "WARNING: --- BAREBACK MODE ----"
|
118
|
-
print_status "WARNING: You are replicating without protection, you can get
|
124
|
+
print_status "WARNING: You are replicating without protection, you can get out of sync in no time"
|
119
125
|
print_status "WARNING: --- BAREBACK MODE ----"
|
120
126
|
end
|
121
127
|
end
|
data/lib/promiscuous/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: promiscuous
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.50.
|
4
|
+
version: 0.50.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -216,8 +216,8 @@ files:
|
|
216
216
|
- lib/promiscuous/subscriber/observer.rb
|
217
217
|
- lib/promiscuous/subscriber/amqp.rb
|
218
218
|
- lib/promiscuous/subscriber/dummy.rb
|
219
|
-
- lib/promiscuous/subscriber/worker.rb
|
220
219
|
- lib/promiscuous/subscriber/model.rb
|
220
|
+
- lib/promiscuous/subscriber/worker.rb
|
221
221
|
- lib/promiscuous/error/subscriber.rb
|
222
222
|
- lib/promiscuous/error/publisher.rb
|
223
223
|
- lib/promiscuous/error/connection.rb
|