carnivore-nsq 0.1.6 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/carnivore-nsq/nsq.rb +50 -7
- data/lib/carnivore-nsq/version.rb +1 -1
- metadata +27 -27
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 51426c18010c2c755db91d0ecc57de7c619252bc
|
4
|
+
data.tar.gz: ba0b5f24e32a1bc41b43f1ee8cadb3f4fa2b8d1c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e344591ee2ea0c053a1a6ece3bf8880dde978a7a329ea215b08a97a89842d0c1cd9249af2c0cf111dbf60eb90819d009cbeab5a02e682295dec2b1df02dbc54
|
7
|
+
data.tar.gz: 43718d3d9f797d829f1e9b8ea19ed95bfa5f86f4a0aaf09822308dab448578176403d3800022d343a775be9c87269b96b02cc5c72ff08d4faf974f979076e4ad
|
data/CHANGELOG.md
CHANGED
data/lib/carnivore-nsq/nsq.rb
CHANGED
@@ -7,6 +7,7 @@ module Carnivore
|
|
7
7
|
|
8
8
|
trap_exit :consumer_failure
|
9
9
|
|
10
|
+
# @return [String] default path for global lookupd configuration
|
10
11
|
DEFAULT_LOOKUPD_PATH = '/etc/carnivore/nsq.json'
|
11
12
|
|
12
13
|
attr_reader(
|
@@ -15,6 +16,9 @@ module Carnivore
|
|
15
16
|
:waiter, :producer_args, :args
|
16
17
|
)
|
17
18
|
|
19
|
+
# Setup the source
|
20
|
+
#
|
21
|
+
# @param args [Hash] setup arguments
|
18
22
|
def setup(args={})
|
19
23
|
@args = args.to_smash
|
20
24
|
@lookupd = (default_lookupds + [args[:lookupd]]).flatten.compact.uniq
|
@@ -27,13 +31,23 @@ module Carnivore
|
|
27
31
|
Krakow::Utils::Logging.level = (Carnivore::Config.get(:krakow, :logging, :level) || :info).to_sym
|
28
32
|
end
|
29
33
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
34
|
+
# Process linked failure
|
35
|
+
#
|
36
|
+
# @param obj [Celluloid::Actor] failed actor
|
37
|
+
# @param exception [Exception] actor exception
|
38
|
+
def consumer_failure(obj, exception)
|
39
|
+
if(exception)
|
40
|
+
exclusive do
|
41
|
+
warn 'Consumer failure detected. Forcing termination and rebuilding.'
|
42
|
+
@reader.terminate
|
43
|
+
@reader = nil
|
44
|
+
build_consumer
|
45
|
+
info "Consumer connection for #{topic}:#{channel} re-established #{reader}"
|
46
|
+
end
|
47
|
+
end
|
35
48
|
end
|
36
49
|
|
50
|
+
# Build the consumer connection
|
37
51
|
def build_consumer
|
38
52
|
consumer_args = Smash.new(
|
39
53
|
:nsqlookupd => lookupd,
|
@@ -46,6 +60,7 @@ module Carnivore
|
|
46
60
|
link @reader
|
47
61
|
end
|
48
62
|
|
63
|
+
# Establish required connections (producer/consumer)
|
49
64
|
def connect
|
50
65
|
unless(callbacks.empty?)
|
51
66
|
unless(lookupd.empty?)
|
@@ -73,34 +88,62 @@ module Carnivore
|
|
73
88
|
end
|
74
89
|
end
|
75
90
|
|
91
|
+
# @return [Krakow::Consumer]
|
76
92
|
def consumer
|
77
93
|
reader ||
|
78
94
|
abort('Consumer is not established. No setup information provided!')
|
79
95
|
end
|
80
96
|
|
97
|
+
# @return [Krakow::Consumer, Krakow::Consumer::Http]
|
81
98
|
def producer
|
82
99
|
writer ||
|
83
100
|
abort('Producer is not established. No setup information provided!')
|
84
101
|
end
|
85
102
|
|
86
|
-
|
103
|
+
# Receive messages
|
104
|
+
#
|
105
|
+
# @return [String]
|
106
|
+
def receive(*_)
|
87
107
|
if(consumer.queue.empty?)
|
88
108
|
waiter.wait
|
89
109
|
end
|
90
110
|
msg = consumer.queue.pop
|
91
111
|
end
|
92
112
|
|
113
|
+
# Send message
|
114
|
+
#
|
115
|
+
# @param payload [Object]
|
116
|
+
# @param original [Carnivore::Message
|
93
117
|
def transmit(payload, original=nil)
|
94
118
|
payload = MultiJson.dump(payload) unless payload.is_a?(String)
|
95
119
|
producer.write(payload)
|
96
120
|
end
|
97
121
|
|
122
|
+
# Confirm completion of message
|
123
|
+
#
|
124
|
+
# @param message [Carnivore::Message]
|
125
|
+
# @return [TrueClass, FalseClass]
|
98
126
|
def confirm(message)
|
99
|
-
|
127
|
+
begin
|
128
|
+
unless(consumer.confirm(message[:message]))
|
129
|
+
error "Failed to confirm payload from source! (#{e})"
|
130
|
+
end
|
131
|
+
rescue Krakow::Error::LookupFailed => e
|
132
|
+
error "Failed to confirm payload from source! (#{e})"
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
# Touch message to extend lifetime
|
137
|
+
#
|
138
|
+
# @param message [Carnivore::Message]
|
139
|
+
# @return [TrueClass]
|
140
|
+
def touch(message)
|
141
|
+
message[:message].touch
|
100
142
|
end
|
101
143
|
|
102
144
|
private
|
103
145
|
|
146
|
+
# @return [Array<String>] default lookupd locations
|
104
147
|
def default_lookupds
|
105
148
|
json_path = args.fetch(:lookupd_file_path, DEFAULT_LOOKUPD_PATH)
|
106
149
|
lookupds = nil
|
metadata
CHANGED
@@ -1,80 +1,80 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: carnivore-nsq
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Roberts
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-12-
|
11
|
+
date: 2014-12-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: carnivore
|
15
|
-
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 0.1.8
|
20
|
-
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
21
23
|
requirements:
|
22
|
-
- -
|
24
|
+
- - ">="
|
23
25
|
- !ruby/object:Gem::Version
|
24
26
|
version: 0.1.8
|
25
|
-
prerelease: false
|
26
|
-
type: :runtime
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: krakow
|
29
|
-
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 0.3.6
|
34
|
-
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
35
37
|
requirements:
|
36
|
-
- -
|
38
|
+
- - ">="
|
37
39
|
- !ruby/object:Gem::Version
|
38
40
|
version: 0.3.6
|
39
|
-
prerelease: false
|
40
|
-
type: :runtime
|
41
41
|
description: Carnivore NSQ source
|
42
42
|
email: chrisroberts.code@gmail.com
|
43
43
|
executables: []
|
44
44
|
extensions: []
|
45
45
|
extra_rdoc_files: []
|
46
46
|
files:
|
47
|
-
- lib/carnivore-nsq.rb
|
48
|
-
- lib/carnivore-nsq/nsq.rb
|
49
|
-
- lib/carnivore-nsq/version.rb
|
50
|
-
- carnivore-nsq.gemspec
|
51
|
-
- README.md
|
52
47
|
- CHANGELOG.md
|
53
48
|
- CONTRIBUTING.md
|
54
49
|
- LICENSE
|
50
|
+
- README.md
|
51
|
+
- carnivore-nsq.gemspec
|
52
|
+
- lib/carnivore-nsq.rb
|
53
|
+
- lib/carnivore-nsq/nsq.rb
|
54
|
+
- lib/carnivore-nsq/version.rb
|
55
55
|
homepage: https://github.com/carnivore-rb/carnivore-nsq
|
56
56
|
licenses:
|
57
57
|
- Apache 2.0
|
58
58
|
metadata: {}
|
59
|
-
post_install_message:
|
59
|
+
post_install_message:
|
60
60
|
rdoc_options: []
|
61
61
|
require_paths:
|
62
62
|
- lib
|
63
63
|
required_ruby_version: !ruby/object:Gem::Requirement
|
64
64
|
requirements:
|
65
|
-
- -
|
65
|
+
- - ">="
|
66
66
|
- !ruby/object:Gem::Version
|
67
67
|
version: '0'
|
68
68
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
69
|
requirements:
|
70
|
-
- -
|
70
|
+
- - ">="
|
71
71
|
- !ruby/object:Gem::Version
|
72
72
|
version: '0'
|
73
73
|
requirements: []
|
74
|
-
rubyforge_project:
|
75
|
-
rubygems_version: 2.
|
76
|
-
signing_key:
|
74
|
+
rubyforge_project:
|
75
|
+
rubygems_version: 2.2.2
|
76
|
+
signing_key:
|
77
77
|
specification_version: 4
|
78
78
|
summary: Message processing helper
|
79
79
|
test_files: []
|
80
|
-
has_rdoc:
|
80
|
+
has_rdoc:
|