gorg_message_sender 1.0.0 → 1.1.0

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: 30d882a3dab9eaa76243ba3104a559695b3f84b3
4
- data.tar.gz: 62f92016e87dce9f8fdb4e719b35312274464632
3
+ metadata.gz: db2318e408f9f7db7fae9a7732cfd5ab61e0e8ff
4
+ data.tar.gz: 56fad971438961d363766324060167f387be1527
5
5
  SHA512:
6
- metadata.gz: b696389acc800543a884cf55d3b5dcb9d96a18a039b1bf6e79d5c7972ff463f9639759fa35c9ffbc558d177bd1c6f669f25cf7a5adcbfa9388d1b74b342e700f
7
- data.tar.gz: a726a69bbafd774ce3758b3f705cedca535c5414edf779f1fc8831ce3ad1ca79db90002496e5f2dffaa7d8030511cff970fd94d668a2596cbe46cd72602022fe
6
+ metadata.gz: aa189e3644f3e409d6a6a7257e5816085c9652cf0159debd7198069b82f6644a1ceb9cb2c0b7686c5adf9da902e3efa02e81ae803decefdd836b1bec73a43258
7
+ data.tar.gz: c46967e71b8f43ed8f200b98919602d07a077d6c782c95101806b0c7274901ac190b438eeaaa5307cc29b0948309c6944acc4d6277219e913abe156e973cc8b2
data/.gitignore CHANGED
@@ -8,3 +8,5 @@
8
8
  /spec/reports/
9
9
  /tmp/
10
10
  *.gem
11
+
12
+ /bin/env.rb
data/README.md CHANGED
@@ -100,12 +100,12 @@ sender.message({this_is: "my data hash"},
100
100
  To send a message, use the `send` command. It expects the same params than `message` :
101
101
  ```ruby
102
102
  sender=GorgMessageSender.new(exchange_name: "my_exchange")
103
- sender.send({this_is: "my data hash"},"some.routing.key")
103
+ sender.send_message({this_is: "my data hash"},"some.routing.key")
104
104
 
105
105
  # Message is sent to the exchange "my_exchange" with routing key "some.routing.key"
106
106
  # => "{\"event_uuid\":\"095dcff6-665d-4194-bdfe-f889f8cedb09\",\"event_name\":\"some.routing.key\",\"event_creation_time\":\"2016-05-31T08:53:32+02:00\",\"event_sender_id\":\"gms\",\"data\":{\"this_is\":\"my data hash\"}}"
107
107
 
108
- sender.send({this_is: "my data hash"},
108
+ sender.send_message({this_is: "my data hash"},
109
109
  "some.routing.key",
110
110
  event_uuid: "8c4abe62-26fe-11e6-b67b-9e71128cae77",
111
111
  event_creation_time: DateTime.new(2084,05,10,01,57,00),
@@ -116,7 +116,7 @@ sender.send({this_is: "my data hash"},
116
116
  # => "{\"event_uuid\":\"8c4abe62-26fe-11e6-b67b-9e71128cae77\",\"event_name\":\"some.routing.key\",\"event_creation_time\":\"2084-05-10T01:57:00+00:00\",\"event_sender_id\":\"some_app_id\",\"data\":{\"this_is\":\"my data hash\"}}"
117
117
 
118
118
 
119
- sender.send({this_is: "my data hash"},
119
+ sender.send_message({this_is: "my data hash"},
120
120
  "some.routing.key",
121
121
  event_uuid: "this is not a valid uuid"
122
122
  )
@@ -124,7 +124,7 @@ sender.send({this_is: "my data hash"},
124
124
  # => RAISE JSON::Schema::ValidationError
125
125
 
126
126
 
127
- sender.message({this_is: "my data hash"},
127
+ sender.message_message({this_is: "my data hash"},
128
128
  "some.routing.key",
129
129
  event_uuid: "this is not a valid uuid",
130
130
  skip_validation: true
@@ -134,10 +134,10 @@ sender.message({this_is: "my data hash"},
134
134
  # => "{\"event_uuid\":\"this is not a valid uuid\",\"event_name\":\"some.routing.key\",\"event_creation_time\":\"2016-05-31T09:15:21+02:00\",\"event_sender_id\":\"gms\",\"data\":{\"this_is\":\"my data hash\"}}"
135
135
  ```
136
136
 
137
- `send`also accepts the `verbose` params to print sending informations in SDOUT
137
+ `send_message`also accepts the `verbose` params to print sending informations in SDOUT
138
138
 
139
139
  ```ruby
140
- sender.send({this_is: "my data hash"},
140
+ sender.send_message({this_is: "my data hash"},
141
141
  "some.routing.key",
142
142
  verbose: true
143
143
  )
data/bin/console CHANGED
@@ -10,5 +10,9 @@ require "gorg_message_sender"
10
10
  # require "pry"
11
11
  # Pry.start
12
12
 
13
+ #You can add a file bin/env.rb to set convenience environment such as configuration
14
+ env_path=File.expand_path("./env.rb",File.dirname(__FILE__))
15
+ require env_path if File.file?(env_path)
16
+
13
17
  require "irb"
14
18
  IRB.start
@@ -59,7 +59,7 @@ class GorgMessageSender
59
59
 
60
60
  protected
61
61
 
62
- def start(opts)
62
+ def conn
63
63
  @conn||=Bunny.new(
64
64
  :hostname => @r_host,
65
65
  :port => @r_port,
@@ -67,11 +67,17 @@ class GorgMessageSender
67
67
  :pass => @r_pass,
68
68
  :vhost => @r_vhost
69
69
  )
70
- @conn.start
71
- ch = @conn.create_channel
70
+ @conn.start unless @_conn.connected?
71
+ @conn
72
+ end
73
+
74
+ def ch
75
+ @_ch = (@_ch && @_ch.status == :open) ? @_ch : conn.create_channe
76
+ end
77
+
78
+ def start(opts)
72
79
  @x = ch.topic(@r_exchange, :durable => @r_durable)
73
80
  puts " [#] Connected as user '#{@r_user}' to #{@r_host}:#{@r_port} on vhost '#{@r_vhost}'" if opts[:verbose]
74
-
75
81
  end
76
82
 
77
83
  def stop(opts)
@@ -1,3 +1,3 @@
1
1
  class GorgMessageSender
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gorg_message_sender
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexandre Narbonne
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-06-07 00:00:00.000000000 Z
11
+ date: 2016-08-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bunny