diff options
author | Kazuki Yamaguchi <k@rhe.jp> | 2015-06-19 11:45:04 +0900 |
---|---|---|
committer | Kazuki Yamaguchi <k@rhe.jp> | 2015-06-19 11:45:04 +0900 |
commit | 8f97973a0f144d4016f7195fd9127f9dd74a21b0 (patch) | |
tree | 4b47dfe9671bfb88b4d266c0fc03334b80aecbe5 /collector_proxy/lib/event_channel.rb | |
parent | 4dc48453453bce1ff96ff2929518ae97c53428ae (diff) | |
parent | 11f6b67874925683b830f6e5ca6999802b95000c (diff) | |
download | aclog-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.rb | 10 |
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 |