onstomp 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +4 -0
- data/.yardopts +2 -1
- data/Rakefile +147 -0
- data/extra_doc/API.md +491 -0
- data/extra_doc/API.md.erb +33 -0
- data/extra_doc/DeveloperNarrative.md +123 -0
- data/extra_doc/UserNarrative.md +511 -0
- data/lib/onstomp.rb +5 -5
- data/lib/onstomp/client.rb +6 -1
- data/lib/onstomp/components/frame.rb +6 -6
- data/lib/onstomp/components/frame_headers.rb +18 -18
- data/lib/onstomp/components/scopes/transaction_scope.rb +11 -11
- data/lib/onstomp/components/subscription.rb +2 -2
- data/lib/onstomp/components/threaded_processor.rb +1 -1
- data/lib/onstomp/components/uri.rb +1 -1
- data/lib/onstomp/connections/base.rb +5 -5
- data/lib/onstomp/connections/heartbeating.rb +2 -2
- data/lib/onstomp/connections/serializers/stomp_1.rb +6 -6
- data/lib/onstomp/connections/serializers/stomp_1_1.rb +2 -2
- data/lib/onstomp/connections/stomp_1_0.rb +1 -1
- data/lib/onstomp/connections/stomp_1_1.rb +1 -1
- data/lib/onstomp/failover.rb +4 -0
- data/lib/onstomp/failover/buffers.rb +1 -0
- data/lib/onstomp/failover/buffers/receipts.rb +101 -0
- data/lib/onstomp/failover/buffers/written.rb +2 -2
- data/lib/onstomp/failover/client.rb +15 -12
- data/lib/onstomp/failover/failover_configurable.rb +3 -3
- data/lib/onstomp/failover/pools/base.rb +1 -1
- data/lib/onstomp/failover/uri.rb +41 -16
- data/lib/onstomp/interfaces/client_configurable.rb +1 -1
- data/lib/onstomp/interfaces/client_events.rb +30 -11
- data/lib/onstomp/interfaces/connection_events.rb +5 -1
- data/lib/onstomp/interfaces/event_manager.rb +2 -2
- data/lib/onstomp/interfaces/frame_methods.rb +169 -8
- data/lib/onstomp/interfaces/uri_configurable.rb +3 -3
- data/lib/onstomp/open-uri/client_extensions.rb +4 -4
- data/lib/onstomp/version.rb +2 -2
- data/onstomp.gemspec +0 -1
- data/spec/onstomp/components/threaded_processor_spec.rb +21 -0
- data/spec/onstomp/connections/base_spec.rb +15 -0
- data/spec/onstomp/failover/buffers/receipts_spec.rb +189 -0
- data/spec/onstomp/failover/buffers/written_spec.rb +167 -1
- data/spec/onstomp/failover/client_spec.rb +70 -1
- data/spec/onstomp/failover/failover_events_spec.rb +1 -2
- data/spec/onstomp/failover/uri_spec.rb +37 -4
- data/spec/onstomp/full_stacks/failover_spec.rb +76 -25
- data/spec/onstomp/full_stacks/onstomp_spec.rb +52 -8
- data/spec/onstomp/full_stacks/onstomp_ssh_spec.rb +83 -0
- data/spec/onstomp/full_stacks/test_broker.rb +45 -29
- metadata +11 -15
- data/DeveloperNarrative.md +0 -15
- data/UserNarrative.md +0 -8
@@ -15,7 +15,7 @@ class OnStomp::Connections::Stomp_1_0 < OnStomp::Connections::Base
|
|
15
15
|
@serializer = OnStomp::Connections::Serializers::Stomp_1_0.new
|
16
16
|
end
|
17
17
|
|
18
|
-
# Creates a SUBSCRIBE frame. Sets
|
18
|
+
# Creates a SUBSCRIBE frame. Sets `ack` header to 'auto' unless it is
|
19
19
|
# already set to 'client'.
|
20
20
|
# @return [OnStomp::Components::Frame] SUBSCRIBE frame
|
21
21
|
def subscribe_frame d, h
|
@@ -31,7 +31,7 @@ class OnStomp::Connections::Stomp_1_1 < OnStomp::Connections::Base
|
|
31
31
|
super && pulse?
|
32
32
|
end
|
33
33
|
|
34
|
-
# Creates a SUBSCRIBE frame. Sets
|
34
|
+
# Creates a SUBSCRIBE frame. Sets `ack` header to 'auto' unless it is
|
35
35
|
# already set to 'client' or 'client-individual'.
|
36
36
|
# @return [OnStomp::Components::Frame] SUBSCRIBE frame
|
37
37
|
def subscribe_frame d, h
|
data/lib/onstomp/failover.rb
CHANGED
@@ -5,6 +5,10 @@ module OnStomp::Failover
|
|
5
5
|
# Raised if the supplied failover: URI is not properly formatted as
|
6
6
|
# +failover:(uri,uri,...)?optionalParams=values+
|
7
7
|
class InvalidFailoverURIError < OnStomp::OnStompError; end
|
8
|
+
|
9
|
+
# Raised if the maximum number of retries is exceed when calling
|
10
|
+
# {OnStomp::Failover::Client#connect}
|
11
|
+
class MaximumRetriesExceededError < OnStomp::OnStompError; end
|
8
12
|
end
|
9
13
|
|
10
14
|
require 'onstomp/failover/uri'
|
@@ -0,0 +1,101 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
# A buffer that ensures frames are RECEIPTed against a
|
4
|
+
# {OnStomp::Client client}'s {OnStomp::Connections::Base connection} and
|
5
|
+
# replays the ones that were not when the
|
6
|
+
# {OnStomp::Failover::Client failover} client reconnects.
|
7
|
+
# @todo Quite a lot of this code is shared between Written and Receipts,
|
8
|
+
# we'll want to factor the common stuff out.
|
9
|
+
class OnStomp::Failover::Buffers::Receipts
|
10
|
+
def initialize failover
|
11
|
+
@failover = failover
|
12
|
+
@buffer_mutex = Mutex.new
|
13
|
+
@buffer = []
|
14
|
+
@txs = {}
|
15
|
+
|
16
|
+
failover.before_send &method(:buffer_frame)
|
17
|
+
failover.before_commit &method(:buffer_frame)
|
18
|
+
failover.before_abort &method(:buffer_frame)
|
19
|
+
failover.before_subscribe &method(:buffer_frame)
|
20
|
+
failover.before_begin &method(:buffer_transaction)
|
21
|
+
# We can scrub the subscription before UNSUBSCRIBE is fully written
|
22
|
+
# because if we replay before UNSUBSCRIBE was sent, we still don't
|
23
|
+
# want to be subscribed when we reconnect.
|
24
|
+
failover.before_unsubscribe &method(:debuffer_subscription)
|
25
|
+
failover.on_receipt &method(:debuffer_frame)
|
26
|
+
|
27
|
+
failover.on_failover_connected &method(:replay)
|
28
|
+
end
|
29
|
+
|
30
|
+
# Adds a frame to a buffer so that it may be replayed if the
|
31
|
+
# {OnStomp::Failover::Client failover} client re-connects
|
32
|
+
def buffer_frame f, *_
|
33
|
+
@buffer_mutex.synchronize do
|
34
|
+
# Don't re-buffer frames that are being replayed.
|
35
|
+
unless f.header? :'x-onstomp-failover-replay'
|
36
|
+
# Create a receipt header, unless the frame already has one.
|
37
|
+
f[:receipt] = OnStomp.next_serial unless f.header?(:receipt)
|
38
|
+
@buffer << f
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
# Records the start of a transaction so that it may be replayed if the
|
44
|
+
# {OnStomp::Failover::Client failover} client re-connects
|
45
|
+
def buffer_transaction f, *_
|
46
|
+
@txs[f[:transaction]] = true
|
47
|
+
buffer_frame f
|
48
|
+
end
|
49
|
+
|
50
|
+
# Removes the recorded transaction from the buffer after it has been
|
51
|
+
# written the broker socket so that it will not be replayed when the
|
52
|
+
# {OnStomp::Failover::Client failover} client re-connects
|
53
|
+
def debuffer_transaction f
|
54
|
+
tx = f[:transaction]
|
55
|
+
if @txs.delete tx
|
56
|
+
@buffer_mutex.synchronize do
|
57
|
+
@buffer.reject! { |bf| bf[:transaction] == tx }
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
# Removes the matching SUBSCRIBE frame from the buffer after the
|
63
|
+
# UNSUBSCRIBE has been added to the connection's write buffer
|
64
|
+
# so that it will not be replayed when the
|
65
|
+
# {OnStomp::Failover::Client failover} client re-connects
|
66
|
+
def debuffer_subscription f, *_
|
67
|
+
@buffer_mutex.synchronize do
|
68
|
+
@buffer.reject! { |bf| bf.command == 'SUBSCRIBE' && bf[:id] == f[:id] }
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
# Removes frames that neither transactional nor SUBSCRIBEs from the buffer
|
73
|
+
# by looking the buffered frames up by their `receipt` header.
|
74
|
+
def debuffer_frame r, *_
|
75
|
+
orig = @buffer_mutex.synchronize do
|
76
|
+
@buffer.detect { |f| f[:receipt] == r[:'receipt-id'] }
|
77
|
+
end
|
78
|
+
if orig
|
79
|
+
# COMMIT and ABORT debuffer the whole transaction sequence
|
80
|
+
if ['COMMIT', 'ABORT'].include? orig.command
|
81
|
+
debuffer_transaction orig
|
82
|
+
# Otherwise, if this isn't part of a transaction, debuffer the
|
83
|
+
# particular frame (if it's not a SUBSCRIBE)
|
84
|
+
elsif orig.command != 'SUBSCRIBE' && !orig.header?(:transaction)
|
85
|
+
@buffer_mutex.synchronize { @buffer.delete orig }
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
# Called when the {OnStomp::Failover::Client failover} client triggers
|
91
|
+
# `on_failover_connected` to start replaying any frames in the buffer.
|
92
|
+
def replay fail, client, *_
|
93
|
+
replay_frames = @buffer_mutex.synchronize do
|
94
|
+
@buffer.select { |f| f[:'x-onstomp-failover-replay'] = '1'; true }
|
95
|
+
end
|
96
|
+
|
97
|
+
replay_frames.each do |f|
|
98
|
+
client.transmit f
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
@@ -10,7 +10,7 @@ class OnStomp::Failover::Buffers::Written
|
|
10
10
|
@buffer_mutex = Mutex.new
|
11
11
|
@buffer = []
|
12
12
|
@txs = {}
|
13
|
-
|
13
|
+
|
14
14
|
failover.before_send &method(:buffer_frame)
|
15
15
|
failover.before_commit &method(:buffer_frame)
|
16
16
|
failover.before_abort &method(:buffer_frame)
|
@@ -78,7 +78,7 @@ class OnStomp::Failover::Buffers::Written
|
|
78
78
|
end
|
79
79
|
|
80
80
|
# Called when the {OnStomp::Failover::Client failover} client triggers
|
81
|
-
#
|
81
|
+
# `on_failover_connected` to start replaying any frames in the buffer.
|
82
82
|
def replay fail, client, *_
|
83
83
|
replay_frames = @buffer_mutex.synchronize do
|
84
84
|
@buffer.select { |f| f[:'x-onstomp-failover-replay'] = '1'; true }
|
@@ -28,25 +28,21 @@ class OnStomp::Failover::Client
|
|
28
28
|
# @return [Fixnum]
|
29
29
|
attr_configurable_int :retry_attempts, :default => 0
|
30
30
|
# Whether or not to randomize the {#client_pool} before connecting through
|
31
|
-
# any of its {OnStomp::Client clients}. Defaults to
|
31
|
+
# any of its {OnStomp::Client clients}. Defaults to `false`
|
32
32
|
# @return [true,false]
|
33
33
|
attr_configurable_bool :randomize, :default => false
|
34
34
|
|
35
35
|
attr_reader :uri, :client_pool, :active_client, :frame_buffer, :connection
|
36
36
|
|
37
37
|
def initialize(uris, options={})
|
38
|
-
|
39
|
-
uris = "failover:(#{uris.map { |u| u.to_s }.join(',')})"
|
40
|
-
end
|
38
|
+
@uri = OnStomp::Failover::URI::FAILOVER.parse uris
|
41
39
|
@client_mutex = Mutex.new
|
42
|
-
@uri = URI.parse(uris)
|
43
40
|
configure_configurable options
|
44
41
|
create_client_pool
|
45
42
|
@active_client = nil
|
46
43
|
@connection = nil
|
47
44
|
@frame_buffer = buffer.new self
|
48
45
|
@disconnecting = false
|
49
|
-
@client_ready = false
|
50
46
|
end
|
51
47
|
|
52
48
|
# Returns true if there is an {#active_client} and it is
|
@@ -76,22 +72,26 @@ class OnStomp::Failover::Client
|
|
76
72
|
# {OnStomp::Client#disconnect disconnect} on the {#active_client}
|
77
73
|
def disconnect *args, &block
|
78
74
|
return unless active_client
|
79
|
-
|
80
|
-
|
81
|
-
|
75
|
+
# If we're not connected, let `reconnect` handle it.
|
76
|
+
#@disconnecting = [args, block]
|
77
|
+
#if connected?
|
78
|
+
@client_mutex.synchronize do
|
79
|
+
@disconnecting = true
|
80
|
+
active_client.disconnect *args, &block
|
81
|
+
end
|
82
|
+
#end
|
82
83
|
end
|
83
84
|
|
84
85
|
private
|
85
86
|
def reconnect
|
86
87
|
@client_mutex.synchronize do
|
87
|
-
@client_ready = false
|
88
88
|
attempt = 1
|
89
89
|
until connected? || retry_exceeded?(attempt)
|
90
90
|
sleep_for_retry attempt
|
91
91
|
begin
|
92
92
|
trigger_failover_retry :before, attempt
|
93
93
|
@active_client = client_pool.next_client
|
94
|
-
#
|
94
|
+
# `reconnect` could be called again within the marked range.
|
95
95
|
active_client.connect # <--- From here
|
96
96
|
@connection = active_client.connection
|
97
97
|
rescue Exception
|
@@ -102,7 +102,10 @@ class OnStomp::Failover::Client
|
|
102
102
|
end
|
103
103
|
connected?.tap do |b|
|
104
104
|
b && trigger_failover_event(:connected, :on, active_client)
|
105
|
-
@
|
105
|
+
#if @disconnecting.is_a?(Array)
|
106
|
+
# args, block = @disconnect
|
107
|
+
# active_client.disconnect *args, &block
|
108
|
+
#end
|
106
109
|
end # <--- Until here
|
107
110
|
end
|
108
111
|
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
# Module for configurable attributes specific to
|
4
4
|
# {OnStomp::Failover::Client failover} clients.
|
5
5
|
module OnStomp::Failover::FailoverConfigurable
|
6
|
-
# Includes {OnStomp::Interfaces::ClientConfigurable} into
|
6
|
+
# Includes {OnStomp::Interfaces::ClientConfigurable} into `base` and
|
7
7
|
# extends {OnStomp::Failover::FailoverConfigurable::ClassMethods}
|
8
8
|
# @param [Module] base
|
9
9
|
def self.included(base)
|
@@ -23,8 +23,8 @@ module OnStomp::Failover::FailoverConfigurable
|
|
23
23
|
|
24
24
|
# Creates readable and writeable attributes that are automatically
|
25
25
|
# converted into boolean values. Assigning the attributes any of
|
26
|
-
#
|
27
|
-
# other values with be treated as
|
26
|
+
# `true`, +'true'+, +'1'+ or +1+ will set the attribute to `true`, all
|
27
|
+
# other values with be treated as `false`. This method will also alias
|
28
28
|
# the reader methods with +attr_name?+
|
29
29
|
def attr_configurable_bool *args, &block
|
30
30
|
trans = attr_configurable_wrap lambda { |v|
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# An abstract pool of clients. This class manages the shared behaviors
|
4
4
|
# of client pools, but has no means of picking successive clients.
|
5
|
-
# Subclasses must define
|
5
|
+
# Subclasses must define `next_client` or pool will not function.
|
6
6
|
class OnStomp::Failover::Pools::Base
|
7
7
|
attr_reader :clients
|
8
8
|
|
data/lib/onstomp/failover/uri.rb
CHANGED
@@ -3,27 +3,52 @@
|
|
3
3
|
# Namespace for failover related URI classes.
|
4
4
|
module OnStomp::Failover::URI
|
5
5
|
# A URI class for representing URIs with a 'failover' scheme.
|
6
|
+
# We don't need to worry about hooking into Ruby's URI parsing jazz since
|
7
|
+
# we have full control over when failover URIs will be created.
|
6
8
|
class FAILOVER < OnStomp::Components::URI::STOMP
|
7
|
-
# Matches the
|
8
|
-
#
|
9
|
-
|
9
|
+
# Matches a failover URI string, grouping the list of real URIs and
|
10
|
+
# any query parameters for the failover URI.
|
11
|
+
FAILOVER_REG = /^failover:(?:\/\/)?\(?([^\)]+)\)?(?:\?(.*))?/
|
10
12
|
|
11
13
|
attr_reader :failover_uris
|
12
|
-
def initialize
|
13
|
-
|
14
|
-
|
14
|
+
def initialize uris, query
|
15
|
+
@failover_uris = uris.map do |u|
|
16
|
+
u.is_a?(::URI) ? u : ::URI.parse(u.strip)
|
17
|
+
end
|
18
|
+
super 'failover', nil, nil, nil, nil, '', "(#{uris.join(',')})", query, nil
|
19
|
+
end
|
20
|
+
|
21
|
+
# Converts a failover URI into a string. Ruby's Generic URIs don't seem
|
22
|
+
# to allow mixing opaques and queries.
|
23
|
+
# @return [String]
|
24
|
+
def to_s
|
25
|
+
base = "#{scheme}:#{opaque}"
|
26
|
+
query.nil? || query.empty? ? base : "#{base}?#{query}"
|
15
27
|
end
|
16
28
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
29
|
+
class << self
|
30
|
+
# Parses a failover URI string or an array of URIs into a
|
31
|
+
# {OnStomp::Failover::URI::FAILOVER} object. Ruby's URI parser works
|
32
|
+
# fine with +failover:(uri1,uri2,..)?params=..+ style URIs, but chokes
|
33
|
+
# on +failover://uri1,uri2,..+ forms. This method gives us a bit more
|
34
|
+
# flexibility.
|
35
|
+
# @note If you are using the +open-uri+ extension with `failover`, you
|
36
|
+
# MUST use the +failover:(uri1,uri2,..)+ form because +open-uri+
|
37
|
+
# relies on +URI.parse+ to convert strings into `URI` objects.
|
38
|
+
# @overload parse(str)
|
39
|
+
# @param [String] str
|
40
|
+
# @return [FAILOVER]
|
41
|
+
# @overload parse(uri_arr)
|
42
|
+
# @param [Array<String or URI>] uri_arr
|
43
|
+
# @return [FAILOVER]
|
44
|
+
def parse uri_str
|
45
|
+
if uri_str.is_a? Array
|
46
|
+
self.new uri_str, nil
|
47
|
+
elsif uri_str =~ FAILOVER_REG
|
48
|
+
self.new $1.split(','), $2
|
49
|
+
else
|
50
|
+
raise OnStomp::Failover::InvalidFailoverURIError, uri_str
|
51
|
+
end
|
27
52
|
end
|
28
53
|
end
|
29
54
|
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# Module for configurable attributes specific to {OnStomp::Client client} objects.
|
4
4
|
module OnStomp::Interfaces::ClientConfigurable
|
5
|
-
# Includes {OnStomp::Interfaces::UriConfigurable} into
|
5
|
+
# Includes {OnStomp::Interfaces::UriConfigurable} into `base` and
|
6
6
|
# extends {OnStomp::Interfaces::ClientConfigurable::ClassMethods}
|
7
7
|
# @param [Module] base
|
8
8
|
def self.included(base)
|
@@ -3,64 +3,77 @@
|
|
3
3
|
# Mixin for {OnStomp::Client client} events
|
4
4
|
# There are a few special event methods that will be passed on
|
5
5
|
# to the client's connection, they are:
|
6
|
-
# *
|
7
|
-
# *
|
8
|
-
# *
|
9
|
-
# *
|
6
|
+
# * `on_connection_established` => {OnStomp::Interfaces::ConnectionEvents#on_established}
|
7
|
+
# * `on_connection_died` => {OnStomp::Interfaces::ConnectionEvents#on_died}
|
8
|
+
# * `on_connection_terminated` => {OnStomp::Interfaces::ConnectionEvents#on_terminated}
|
9
|
+
# * `on_connection_closed` => {OnStomp::Interfaces::ConnectionEvents#on_closed}
|
10
10
|
module OnStomp::Interfaces::ClientEvents
|
11
11
|
include OnStomp::Interfaces::EventManager
|
12
12
|
|
13
13
|
# @group Client Frame Event Bindings
|
14
14
|
|
15
|
-
#
|
15
|
+
# @api gem:1 STOMP:1.0,1.1
|
16
|
+
# Can't get `before` because the CONNECT frame isn't transmitted by
|
16
17
|
# the client.
|
18
|
+
# @yield [frame, client] callback invoked when event is triggered
|
19
|
+
# @yieldparam [OnStomp::Components::Frame] frame
|
20
|
+
# @yieldparam [OnStomp::Client] client
|
17
21
|
create_event_methods :connect, :on
|
18
|
-
|
22
|
+
# @api gem:1 STOMP:1.0,1.1
|
19
23
|
# Binds a callback to be invoked when an ACK frame is transmitted
|
20
24
|
# @yield [frame, client] callback invoked when event is triggered
|
21
25
|
# @yieldparam [OnStomp::Components::Frame] frame
|
22
26
|
# @yieldparam [OnStomp::Client] client
|
23
27
|
create_event_methods :ack, :before, :on
|
28
|
+
# @api gem:1 STOMP:1.1
|
24
29
|
# Binds a callback to be invoked when a NACK frame is transmitted
|
25
30
|
# @yield [frame, client] callback invoked when event is triggered
|
26
31
|
# @yieldparam [OnStomp::Components::Frame] frame
|
27
32
|
# @yieldparam [OnStomp::Client] client
|
28
33
|
create_event_methods :nack, :before, :on
|
34
|
+
# @api gem:1 STOMP:1.0,1.1
|
29
35
|
# Binds a callback to be invoked when a BEGIN frame is transmitted
|
30
36
|
# @yield [frame, client] callback invoked when event is triggered
|
31
37
|
# @yieldparam [OnStomp::Components::Frame] frame
|
32
38
|
# @yieldparam [OnStomp::Client] client
|
33
39
|
create_event_methods :begin, :before, :on
|
40
|
+
# @api gem:1 STOMP:1.0,1.1
|
34
41
|
# Binds a callback to be invoked when an ABORT frame is transmitted
|
35
42
|
# @yield [frame, client] callback invoked when event is triggered
|
36
43
|
# @yieldparam [OnStomp::Components::Frame] frame
|
37
44
|
# @yieldparam [OnStomp::Client] client
|
38
45
|
create_event_methods :abort, :before, :on
|
46
|
+
# @api gem:1 STOMP:1.0,1.1
|
39
47
|
# Binds a callback to be invoked when a COMMIT frame is transmitted
|
40
48
|
# @yield [frame, client] callback invoked when event is triggered
|
41
49
|
# @yieldparam [OnStomp::Components::Frame] frame
|
42
50
|
# @yieldparam [OnStomp::Client] client
|
43
51
|
create_event_methods :commit, :before, :on
|
52
|
+
# @api gem:1 STOMP:1.0,1.1
|
44
53
|
# Binds a callback to be invoked when a SEND frame is transmitted
|
45
54
|
# @yield [frame, client] callback invoked when event is triggered
|
46
55
|
# @yieldparam [OnStomp::Components::Frame] frame
|
47
56
|
# @yieldparam [OnStomp::Client] client
|
48
57
|
create_event_methods :send, :before, :on
|
58
|
+
# @api gem:1 STOMP:1.0,1.1
|
49
59
|
# Binds a callback to be invoked when a SUBSCRIBE frame is transmitted
|
50
60
|
# @yield [frame, client] callback invoked when event is triggered
|
51
61
|
# @yieldparam [OnStomp::Components::Frame] frame
|
52
62
|
# @yieldparam [OnStomp::Client] client
|
53
63
|
create_event_methods :subscribe, :before, :on
|
64
|
+
# @api gem:1 STOMP:1.0,1.1
|
54
65
|
# Binds a callback to be invoked when an UNSUBSCRIBE frame is transmitted
|
55
66
|
# @yield [frame, client] callback invoked when event is triggered
|
56
67
|
# @yieldparam [OnStomp::Components::Frame] frame
|
57
68
|
# @yieldparam [OnStomp::Client] client
|
58
69
|
create_event_methods :unsubscribe, :before, :on
|
70
|
+
# @api gem:1 STOMP:1.0,1.1
|
59
71
|
# Binds a callback to be invoked when a DISCONNECT frame is transmitted
|
60
72
|
# @yield [frame, client] callback invoked when event is triggered
|
61
73
|
# @yieldparam [OnStomp::Components::Frame] frame
|
62
74
|
# @yieldparam [OnStomp::Client] client
|
63
75
|
create_event_methods :disconnect, :before, :on
|
76
|
+
# @api gem:1 STOMP:1.1
|
64
77
|
# Binds a callback to be invoked when a client heartbeat is transmitted
|
65
78
|
# @yield [frame, client] callback invoked when event is triggered
|
66
79
|
# @yieldparam [OnStomp::Components::Frame] frame
|
@@ -68,22 +81,26 @@ module OnStomp::Interfaces::ClientEvents
|
|
68
81
|
create_event_methods :client_beat, :before, :on
|
69
82
|
|
70
83
|
# @group Broker Frame Event Bindings
|
71
|
-
|
84
|
+
|
85
|
+
# @api gem:1 STOMP:1.0,1.1
|
72
86
|
# Binds a callback to be invoked when an ERROR frame is received
|
73
87
|
# @yield [frame, client] callback invoked when event is triggered
|
74
88
|
# @yieldparam [OnStomp::Components::Frame] frame
|
75
89
|
# @yieldparam [OnStomp::Client] client
|
76
90
|
create_event_methods :error, :before, :on
|
91
|
+
# @api gem:1 STOMP:1.0,1.1
|
77
92
|
# Binds a callback to be invoked when a MESSAGE frame is received
|
78
93
|
# @yield [frame, client] callback invoked when event is triggered
|
79
94
|
# @yieldparam [OnStomp::Components::Frame] frame
|
80
95
|
# @yieldparam [OnStomp::Client] client
|
81
96
|
create_event_methods :message, :before, :on
|
97
|
+
# @api gem:1 STOMP:1.0,1.1
|
82
98
|
# Binds a callback to be invoked when a RECEIPT frame is received
|
83
99
|
# @yield [frame, client] callback invoked when event is triggered
|
84
100
|
# @yieldparam [OnStomp::Components::Frame] frame
|
85
101
|
# @yieldparam [OnStomp::Client] client
|
86
102
|
create_event_methods :receipt, :before, :on
|
103
|
+
# @api gem:1 STOMP:1.1
|
87
104
|
# Binds a callback to be invoked when a broker heartbeat is received
|
88
105
|
# @yield [frame, client] callback invoked when event is triggered
|
89
106
|
# @yieldparam [OnStomp::Components::Frame] frame
|
@@ -92,11 +109,13 @@ module OnStomp::Interfaces::ClientEvents
|
|
92
109
|
|
93
110
|
# @group Frame Exchange Event Bindings
|
94
111
|
|
112
|
+
# @api gem:1 STOMP:1.0,1.1
|
95
113
|
# Binds a callback to be invoked when any frame is transmitted
|
96
114
|
# @yield [frame, client] callback invoked when event is triggered
|
97
115
|
# @yieldparam [OnStomp::Components::Frame] frame
|
98
116
|
# @yieldparam [OnStomp::Client] client
|
99
117
|
create_event_methods :transmitting, :before, :after
|
118
|
+
# @api gem:1 STOMP:1.0,1.1
|
100
119
|
# Binds a callback to be invoked when any frame is received
|
101
120
|
# @yield [frame, client] callback invoked when event is triggered
|
102
121
|
# @yieldparam [OnStomp::Components::Frame] frame
|
@@ -139,7 +158,7 @@ module OnStomp::Interfaces::ClientEvents
|
|
139
158
|
end
|
140
159
|
|
141
160
|
# Triggers the :before_receiving event and the
|
142
|
-
#
|
161
|
+
# `before` prefixed frame specific event (eg: +:before_error+).
|
143
162
|
# @param [OnStomp::Components::Frame] f
|
144
163
|
def trigger_before_receiving f
|
145
164
|
trigger_event :before_receiving, f, self
|
@@ -147,7 +166,7 @@ module OnStomp::Interfaces::ClientEvents
|
|
147
166
|
end
|
148
167
|
|
149
168
|
# Triggers the :after_receiving event and the
|
150
|
-
#
|
169
|
+
# `on` prefixed frame specific event (eg: +:on_message+)
|
151
170
|
# @param [OnStomp::Components::Frame] f
|
152
171
|
def trigger_after_receiving f
|
153
172
|
trigger_event :after_receiving, f, self
|
@@ -155,7 +174,7 @@ module OnStomp::Interfaces::ClientEvents
|
|
155
174
|
end
|
156
175
|
|
157
176
|
# Triggers the :before_transmitting event and the
|
158
|
-
#
|
177
|
+
# `before` prefixed frame specific event (eg: +:before_disconnect+).
|
159
178
|
# @param [OnStomp::Components::Frame] f
|
160
179
|
def trigger_before_transmitting f
|
161
180
|
trigger_event :before_transmitting, f, self
|
@@ -163,7 +182,7 @@ module OnStomp::Interfaces::ClientEvents
|
|
163
182
|
end
|
164
183
|
|
165
184
|
# Triggers the :after_transmitting event and the
|
166
|
-
#
|
185
|
+
# `on` prefixed frame specific event (eg: +:on_send+).
|
167
186
|
# @param [OnStomp::Components::Frame] f
|
168
187
|
def trigger_after_transmitting f
|
169
188
|
trigger_event :after_transmitting, f, self
|