bmc-daemon-lib 0.3.14 → 0.3.16

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fef18aedd6818e48a75388b4846eed1888c99798
4
- data.tar.gz: 6a9cc6898093c487798628a1bb2e2c5af6657d24
3
+ metadata.gz: 979aa39471d0f78ea2463c44e0471def495dbfc9
4
+ data.tar.gz: 3fab11319297f7f7c77c1cb2b6056cf72f492856
5
5
  SHA512:
6
- metadata.gz: 646b6fe2be7e4716b3e50cd5b9307ba769105b949f65a0727c82c3d29053998002ee56d80d01f4fb84abaf36a8d93d69d69116a169ecc57739388c5e4d24916a
7
- data.tar.gz: 7f8b49162ab83e593fe0b7a3b7572c71128591d48fca1af62666a7a60f7185faa30c53fc51a0fb670a197e2095d454669ee25544e9b92342e0bd2634f54f992d
6
+ metadata.gz: 4c005bc13c44b365c8b207e12412ff710c0605dfbf0685ec5962c8c620c27fa37d633c2f3f3f7ced7c251a9f2d37dd7214c1d8de2bf64a1c7a3f661d498930ce
7
+ data.tar.gz: 2a2813cd028bbfd6d656aca6f33bf6d1be415032dc75f16e35f2a16fa93c1eccd1f2f17961935b5f17afc5240acc693acd85e22772b294393c375f1e4e99ae84
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bmc-daemon-lib (0.3.14)
4
+ bmc-daemon-lib (0.3.16)
5
5
  chamber (~> 2.9)
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  # coding: utf-8
2
2
  Gem::Specification.new do |spec|
3
3
  # Project version
4
- spec.version = "0.3.14"
4
+ spec.version = "0.3.16"
5
5
 
6
6
  # Project description
7
7
  spec.name = "bmc-daemon-lib"
@@ -3,6 +3,7 @@ require "rubygems"
3
3
  require "syslog"
4
4
  require "thread"
5
5
  require "chamber"
6
+ require "time"
6
7
 
7
8
  # Project's libs
8
9
  require_relative "bmc-daemon-lib/conf"
@@ -9,6 +9,7 @@ module BmcDaemonLib
9
9
  LOG_ROTATION = "daily"
10
10
 
11
11
  def get pipe = nil
12
+ # If not provided, use :default
12
13
  pipe = :default if pipe.to_s.empty?
13
14
 
14
15
  @loggers ||= {}
@@ -1,5 +1,8 @@
1
+ require 'time'
2
+
1
3
  module BmcDaemonLib
2
4
  class MqConsumerError < StandardError; end
5
+ class MqConsumerException < StandardError; end
3
6
 
4
7
  class MqConsumer < MqEndpoint
5
8
 
@@ -56,6 +59,12 @@ module BmcDaemonLib
56
59
  rkey: msg_rkey,
57
60
  tag: msg_tag,
58
61
  data: msg_data
62
+
63
+ # Handle errors
64
+ rescue StandardError => e
65
+ #puts "handle_receive: exception: #{e.inspect}"
66
+ log_error "UNEXPECTED EXCEPTION: #{e.inspect}"
67
+ raise MqConsumerException, e.message
59
68
  end
60
69
 
61
70
  def consumer_cancelled all={}
@@ -63,15 +72,19 @@ module BmcDaemonLib
63
72
  end
64
73
 
65
74
  def extract_delay msg_headers
66
- return unless msg_headers['sent_at']
75
+ sent_at = msg_headers['sent_at'].to_s
76
+ return if sent_at.empty?
67
77
 
68
78
  # Extract sent_at header
69
- sent_at = Time.iso8601(msg_headers['sent_at']) rescue nil
70
- # log_info "sent_at : #{sent_at.to_f}"
71
- # log_info "timenow : #{Time.now.to_f}"
79
+ sent_at = Time.parse(msg_headers['sent_at'])
80
+
81
+ rescue StandardError => ex
82
+ log_error "extract_delay: can't parse sent_at [#{sent_at}] (#{ex.message})"
83
+ return nil
72
84
 
73
- # Compute delay
74
- return ((Time.now - sent_at)*1000).round(2)
85
+ else
86
+ # Compute delay
87
+ return ((Time.now - sent_at)*1000).round(2)
75
88
  end
76
89
 
77
90
  def handle_message context, metadata, delivery_info, message = {}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bmc-daemon-lib
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.14
4
+ version: 0.3.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bruno MEDICI