aboutsummaryrefslogtreecommitdiffstats
path: root/collector_proxy/lib/event_channel.rb
diff options
context:
space:
mode:
authorKazuki Yamaguchi <k@rhe.jp>2015-06-19 11:45:04 +0900
committerKazuki Yamaguchi <k@rhe.jp>2015-06-19 11:45:04 +0900
commit8f97973a0f144d4016f7195fd9127f9dd74a21b0 (patch)
tree4b47dfe9671bfb88b4d266c0fc03334b80aecbe5 /collector_proxy/lib/event_channel.rb
parent4dc48453453bce1ff96ff2929518ae97c53428ae (diff)
parent11f6b67874925683b830f6e5ca6999802b95000c (diff)
downloadaclog-collector-proxy.tar.gz
Merge branch 'collector-proxy' of gitlab.rhe.jp:rhenium/aclog into collector-proxycollector-proxy
Diffstat (limited to 'collector_proxy/lib/event_channel.rb')
-rw-r--r--collector_proxy/lib/event_channel.rb10
1 files changed, 6 insertions, 4 deletions
diff --git a/collector_proxy/lib/event_channel.rb b/collector_proxy/lib/event_channel.rb
index 5c394c2..55fdebd 100644
--- a/collector_proxy/lib/event_channel.rb
+++ b/collector_proxy/lib/event_channel.rb
@@ -2,7 +2,7 @@ class EventChannel
class << self
def setup
return if @dalli
- @dalli = Dalli::Client.new(Settings.memcached, namespace: "aclog-collector-proxy:")
+ @dalli = Dalli::Client.new(Settings.memcached, namespace: "aclog-collector-proxy")
@queue = []
@subscribers = {}
end
@@ -10,11 +10,13 @@ class EventChannel
def push(data)
raise ScriptError, "Call EventChannel.setup first" unless @dalli
if id = data[:identifier]
- if @dalli.get(id)
- CollectorProxy.logger.debug("UniqueChannel") { "Duplicate event: #{id}" }
+ key, val = id.split("#", 2)
+ cur = @dalli.get(key)
+ if cur && (!val || (cur <=> val) > -1)
+ CollectorProxy.logger.debug("UniqueChannel") { "Duplicate event: #{key}" }
return
else
- @dalli.set(id, true)
+ @dalli.set(key, val || true)
end
end
if @subscribers.size > 0