pubnub 4.7.0 → 4.7.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of pubnub might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.pubnub.yml +11 -4
- data/CHANGELOG.md +21 -12
- data/Gemfile.lock +1 -1
- data/VERSION +1 -1
- data/lib/pubnub/client/paged_history.rb +144 -17
- data/lib/pubnub/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c52a9cfe08cbc90c671a74610beb900b5627c81e9f24da57e0c60530aa05c5b9
|
4
|
+
data.tar.gz: 5dd3300e2b6667e2364ab3e6d56f6583d3ca1eb71caa1839e9e97d3dbe68ec50
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3385c44fe3b07c3f84ff233e3bc42456e0907ff56e2fd65bd6197b2bcaa6edd75c3d53268959bb1491b88e7eaf3e49308a3afbed86a3bbebc2062364336b95be
|
7
|
+
data.tar.gz: 50506cf261d7d8c8240b8a25683dbe1032ebbb99b4f9dc3ba609228672fb8e3609ee43c3a0cc94052e8d80177e7e3554ee8b57458275d5a9865b37b7ad81ca1a
|
data/.pubnub.yml
CHANGED
@@ -1,6 +1,13 @@
|
|
1
1
|
---
|
2
|
-
version: "4.7.
|
2
|
+
version: "4.7.1"
|
3
3
|
changelog:
|
4
|
+
- date: 2021-11-24
|
5
|
+
version: v4.7.1
|
6
|
+
changes:
|
7
|
+
- type: feature
|
8
|
+
text: "Add new method `all_history_messages` which return messages from requested interval or `since` / `before` date in single object."
|
9
|
+
- type: bug
|
10
|
+
text: "Fix exception raised when optional start / end not passed to `paged_history`."
|
4
11
|
- date: 2021-11-09
|
5
12
|
version: v4.7.0
|
6
13
|
changes:
|
@@ -605,7 +612,7 @@ sdks:
|
|
605
612
|
- x86-64
|
606
613
|
- distribution-type: package
|
607
614
|
distribution-repository: RubyGems
|
608
|
-
package-name: pubnub-4.7.
|
615
|
+
package-name: pubnub-4.7.1.gem
|
609
616
|
location: https://rubygems.org/gems/pubnub
|
610
617
|
requires:
|
611
618
|
- name: addressable
|
@@ -710,8 +717,8 @@ sdks:
|
|
710
717
|
- x86-64
|
711
718
|
- distribution-type: library
|
712
719
|
distribution-repository: GitHub release
|
713
|
-
package-name: pubnub-
|
714
|
-
location: https://github.com/pubnub/ruby/releases/download/v4.7.
|
720
|
+
package-name: pubnub-4.7.1.gem
|
721
|
+
location: https://github.com/pubnub/ruby/releases/download/v4.7.1/pubnub-4.7.1.gem
|
715
722
|
requires:
|
716
723
|
- name: addressable
|
717
724
|
min-version: 2.0.0
|
data/CHANGELOG.md
CHANGED
@@ -1,19 +1,28 @@
|
|
1
|
-
## v4.7.
|
2
|
-
November
|
1
|
+
## v4.7.1
|
2
|
+
November 24 2021
|
3
3
|
|
4
4
|
#### Added
|
5
|
-
-
|
5
|
+
- Add new method `all_history_messages` which return messages from requested interval or `since` / `before` date in single object.
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
- Add new `sdks` section to `.pubnub.yml` with information about available artifacts and distribution variants.
|
10
|
-
|
11
|
-
##### v4.6.1
|
12
|
-
|
13
|
-
- Exclude `spec` and `fixtures` from built gem file.
|
14
|
-
- Fix Ruby SDK repository location under `sdks` section in `.pubnub.yml`.
|
15
|
-
- Add new section to `.pubnub.yml` file with information about SDK and destribution types.
|
7
|
+
#### Fixed
|
8
|
+
- Fix exception raised when optional start / end not passed to `paged_history`.
|
16
9
|
|
10
|
+
## v4.7.0
|
11
|
+
November 09 2021
|
12
|
+
|
13
|
+
#### Added
|
14
|
+
- Grant_token allows generation of signed token with permissions for channels, channel groups and uuids.
|
15
|
+
|
16
|
+
##### v4.6.2
|
17
|
+
|
18
|
+
- Add new `sdks` section to `.pubnub.yml` with information about available artifacts and distribution variants.
|
19
|
+
|
20
|
+
##### v4.6.1
|
21
|
+
|
22
|
+
- Exclude `spec` and `fixtures` from built gem file.
|
23
|
+
- Fix Ruby SDK repository location under `sdks` section in `.pubnub.yml`.
|
24
|
+
- Add new section to `.pubnub.yml` file with information about SDK and destribution types.
|
25
|
+
|
17
26
|
##### v4.6.0
|
18
27
|
|
19
28
|
- BREAKING CHANGE: Add randomized initialization vector usage by default for data encryption / decryption in publish / subscribe / history API calls.
|
data/Gemfile.lock
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
4.7.
|
1
|
+
4.7.1
|
@@ -1,19 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Toplevel Pubnub module.
|
2
4
|
module Pubnub
|
3
5
|
# Pubnub client Class
|
4
6
|
class Client
|
5
7
|
# Module that holds paged_history event logic
|
6
8
|
module PagedHistory
|
9
|
+
# Fetch messages as long as one of criteria won't be met.
|
10
|
+
# Messages returned as single envelope.
|
11
|
+
def all_history_messages(options = {}, &block)
|
12
|
+
channel = options.fetch(:channel)
|
13
|
+
# Time frame between which messages should be fetched.
|
14
|
+
start_tt = options.fetch(:start, nil)
|
15
|
+
end_tt = options.fetch(:end, nil)
|
16
|
+
page_size = options.fetch(:page_size, 100) # How many messages per-request should be fetched.
|
17
|
+
reverse = options.fetch(:reverse, false) # Order in which messages should be retrieved if :end not set.
|
18
|
+
include_token = options.fetch(:include_token, true) # Whether timetoken should be included with message or not.
|
19
|
+
maximum = options.fetch(:max, 500) # Maximum number of messages which should be fetched.
|
20
|
+
callback = options.fetch(:callback, block)
|
21
|
+
|
22
|
+
reverse = false unless end_tt.nil? # Disable revers if closed time interval specified.
|
23
|
+
maximum = nil unless end_tt.nil? # Disable maximum messages count if closed time interval specified.
|
24
|
+
|
25
|
+
if options[:http_sync]
|
26
|
+
sync_all_history_messages(channel, include_token, page_size, reverse, maximum, callback, start: start_tt, end: end_tt)
|
27
|
+
else
|
28
|
+
async_all_history_messages(options)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
7
32
|
def paged_history(options = {}, &block)
|
8
33
|
channel = options.fetch(:channel)
|
9
|
-
page = options.fetch(:page, 1)
|
10
|
-
limit = options.fetch(:limit, 100)
|
34
|
+
page = options.fetch(:page, 1) # How many mages should be fetched with specified limit.
|
35
|
+
limit = options.fetch(:limit, 100) # How many messages per page should be fetched.
|
36
|
+
include_token = options.fetch(:include_token, false) # Whether timetoken should be included with message or not.
|
11
37
|
callback = options.fetch(:callback, block)
|
12
|
-
|
13
|
-
start_tt = options.fetch(:start)
|
14
|
-
end_tt = options.fetch(:end)
|
15
|
-
|
16
|
-
|
38
|
+
# Time frame between which messages should be fetched.
|
39
|
+
start_tt = options.fetch(:start, nil)
|
40
|
+
end_tt = options.fetch(:end, nil)
|
41
|
+
|
42
|
+
if options[:http_sync]
|
43
|
+
sync_paged_history(channel, page, limit, include_token, callback, start: start_tt, end: end_tt)
|
17
44
|
else
|
18
45
|
async_paged_history(options)
|
19
46
|
end
|
@@ -21,40 +48,140 @@ module Pubnub
|
|
21
48
|
|
22
49
|
private
|
23
50
|
|
24
|
-
def
|
51
|
+
def sync_all_history_messages(channel, include_token, page_size, reverse, maximum, callback, timetokens)
|
52
|
+
next_timetoken = timetokens[:start]
|
53
|
+
messages_timetokens = timetokens.dup
|
54
|
+
final_envelope = nil
|
55
|
+
keep_fetching = true
|
56
|
+
messages = []
|
57
|
+
|
58
|
+
while keep_fetching
|
59
|
+
envelope = history(
|
60
|
+
channel: channel,
|
61
|
+
include_token: include_token,
|
62
|
+
count: page_size,
|
63
|
+
reverse: reverse,
|
64
|
+
start: next_timetoken,
|
65
|
+
end: timetokens[:end],
|
66
|
+
http_sync: true
|
67
|
+
)
|
68
|
+
|
69
|
+
# Terminate fetch because last attempt failed.
|
70
|
+
if envelope.status[:category] != :ack
|
71
|
+
final_envelope = envelope
|
72
|
+
break
|
73
|
+
end
|
74
|
+
|
75
|
+
result_data = envelope.result[:data]
|
76
|
+
result_messages = result_data[:messages]
|
77
|
+
break if result_messages.empty?
|
78
|
+
|
79
|
+
if reverse || timetokens[:end]
|
80
|
+
messages_timetokens[:start] = result_data[:start].to_i if messages.empty?
|
81
|
+
messages_timetokens[:end] = result_data[:end].to_i
|
82
|
+
messages.concat(result_messages)
|
83
|
+
else
|
84
|
+
messages_timetokens[:end] = result_data[:end].to_i if messages.empty?
|
85
|
+
messages_timetokens[:start] = result_data[:start].to_i
|
86
|
+
messages.unshift(*result_messages)
|
87
|
+
end
|
88
|
+
|
89
|
+
keep_fetching = result_messages.length == page_size
|
90
|
+
keep_fetching = messages.length < maximum if keep_fetching && maximum && maximum > 0
|
91
|
+
|
92
|
+
if keep_fetching
|
93
|
+
next_timetoken = reverse ? result_data[:end].to_i : result_data[:start].to_i
|
94
|
+
next_timetoken = result_data[:end].to_i unless timetokens[:end].nil?
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
# Create envelop if no error should be reported.
|
99
|
+
final_envelope = envelope_with_messages(messages, messages_timetokens) if final_envelope.nil?
|
100
|
+
|
101
|
+
callback&.call final_envelope
|
102
|
+
final_envelope
|
103
|
+
end
|
104
|
+
|
105
|
+
# Retrieve results page-by-page (callback called for each page).
|
106
|
+
def sync_paged_history(channel, page, limit, include_token, callback, timetokens)
|
25
107
|
envelopes = []
|
26
|
-
page.times do |
|
27
|
-
|
108
|
+
page.times do |_i|
|
109
|
+
envelope = history(
|
28
110
|
channel: channel,
|
111
|
+
include_token: include_token,
|
29
112
|
http_sync: true,
|
30
113
|
count: limit,
|
31
114
|
start: timetokens[:start],
|
32
115
|
end: timetokens[:end]
|
33
116
|
)
|
34
|
-
|
35
|
-
|
36
|
-
|
117
|
+
|
118
|
+
break if envelope.result[:data][:messages].empty?
|
119
|
+
|
120
|
+
envelopes.push envelope
|
121
|
+
timetokens[:start] = envelope.result[:data][:start].to_i
|
122
|
+
# No need to iterate further if there is no more messages.
|
123
|
+
break if envelope.result[:data][:messages].length < limit
|
37
124
|
end
|
38
125
|
|
39
126
|
call_callback(envelopes, callback)
|
40
127
|
end
|
41
128
|
|
42
129
|
def async_paged_history(options)
|
43
|
-
Concurrent::Future.
|
130
|
+
Concurrent::Future.execute do
|
44
131
|
sync_options = options.dup
|
45
132
|
sync_options[:http_sync] = true
|
46
|
-
paged_history(sync_options
|
133
|
+
paged_history(sync_options)
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
def async_all_history_messages(options)
|
138
|
+
Concurrent::Future.execute do
|
139
|
+
sync_options = options.dup
|
140
|
+
sync_options[:http_sync] = true
|
141
|
+
all_history_messages(sync_options)
|
47
142
|
end
|
48
143
|
end
|
49
144
|
|
50
145
|
def call_callback(envelopes, callback)
|
51
|
-
envelopes.flatten!
|
52
146
|
if callback
|
53
147
|
envelopes.each do |envelope|
|
54
|
-
|
148
|
+
callback.call envelope
|
55
149
|
end
|
56
150
|
end
|
57
151
|
envelopes
|
152
|
+
rescue StandardError => e
|
153
|
+
Pubnub.logger.error('Pubnub::Client') { "Error while calling callback #{e.inspect}" }
|
154
|
+
end
|
155
|
+
|
156
|
+
def envelope_with_messages(messages, timetokens)
|
157
|
+
Pubnub::Envelope.new(
|
158
|
+
event: :history,
|
159
|
+
event_options: nil,
|
160
|
+
timetoken: nil,
|
161
|
+
status: {
|
162
|
+
code: 200,
|
163
|
+
client_request: nil,
|
164
|
+
server_response: nil,
|
165
|
+
|
166
|
+
category: Pubnub::Constants::STATUS_ACK,
|
167
|
+
error: false,
|
168
|
+
auto_retried: false,
|
169
|
+
|
170
|
+
data: nil,
|
171
|
+
current_timetoken: nil,
|
172
|
+
last_timetoken: nil,
|
173
|
+
subscribed_channels: nil,
|
174
|
+
subscribed_channel_groups: nil,
|
175
|
+
config: nil
|
176
|
+
},
|
177
|
+
result: {
|
178
|
+
code: 200,
|
179
|
+
operation: Pubnub::Constants::OPERATION_HISTORY,
|
180
|
+
client_request: nil,
|
181
|
+
server_response: nil,
|
182
|
+
data: { messages: messages, end: timetokens[:end], start: timetokens[:start] }
|
183
|
+
}
|
184
|
+
)
|
58
185
|
end
|
59
186
|
end
|
60
187
|
end
|
data/lib/pubnub/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pubnub
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.7.
|
4
|
+
version: 4.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- PubNub
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-11-
|
11
|
+
date: 2021-11-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|