Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eventEngine #334

Merged
merged 67 commits into from
Jan 16, 2024
Merged
Changes from 1 commit
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
ab2b9d9
feat: cucumber refactor
are Nov 4, 2022
d1fad58
feat: add more steps
are Nov 30, 2022
95b6674
Merge branch 'master' of github.com:pubnub/javascript into feat/cucum…
are Apr 3, 2023
11a5670
feat: current progress
are May 12, 2023
eb35e90
refactor event-engine(from draft PR)
mohitpubnub May 19, 2023
f41d248
event-engine: update to latest description, added some missing transi…
mohitpubnub May 19, 2023
6dd1294
prettier!
mohitpubnub May 19, 2023
ab2b566
take: fix hanging tests due to retry intro
mohitpubnub Jun 14, 2023
64d2371
update as per latest event engine specs
mohitpubnub Jun 26, 2023
85af6b4
Merge branch 'master' into CLEN-1127
mohitpubnub Jun 26, 2023
8afa248
* cucumber tsflow
mohitpubnub Jul 6, 2023
c030e31
prettier!
mohitpubnub Jul 6, 2023
e01236c
fix: test and version mismatch from branch merge
mohitpubnub Jul 6, 2023
4f77d20
fix: version
mohitpubnub Jul 6, 2023
0ac5cc7
add: reconnection configuration
mohitpubnub Jul 11, 2023
ecd43ca
Merge branch 'CLEN-1127' into CLEN_1361_event_engine_test
mohitpubnub Jul 11, 2023
1c376a9
lint/prettier
mohitpubnub Jul 11, 2023
09d7708
fix: test. destroy() not required
mohitpubnub Jul 11, 2023
0a2e391
fix: naming convention and removed unnecessary effect dispatch
mohitpubnub Jul 11, 2023
701a44f
WIP: presence event engine
mohitpubnub Aug 18, 2023
b377b3c
organised files and directories for presence
mohitpubnub Aug 18, 2023
9096100
fix: paths
mohitpubnub Aug 18, 2023
325fd52
fix: lint
mohitpubnub Aug 22, 2023
bb6809e
presence and subscribe event engine states
mohitpubnub Jan 8, 2024
ae98076
event engine effects and events
mohitpubnub Jan 8, 2024
e1e02cc
retry policy configuration
mohitpubnub Jan 8, 2024
85dc261
event engines tests
mohitpubnub Jan 8, 2024
69ce948
updated stateless utilities
mohitpubnub Jan 8, 2024
c253e96
updated PubNub with configurations
mohitpubnub Jan 8, 2024
f7b92ad
lib and dist
mohitpubnub Jan 8, 2024
528ca45
take-1 fix lint
mohitpubnub Jan 8, 2024
037378d
fix: elint config
mohitpubnub Jan 8, 2024
ea4b588
Merge remote-tracking branch 'origin/master' into presence
mohitpubnub Jan 8, 2024
944caca
sync: package-lock
mohitpubnub Jan 8, 2024
b57361f
fix: package-lock
mohitpubnub Jan 8, 2024
128c678
WIP take-1(non-status events): Listener compatibility with eventEngine
mohitpubnub Jan 9, 2024
200df8c
take-2: (presence) listener structs backward compatibility.
mohitpubnub Jan 9, 2024
1b4d38e
lib and dist
mohitpubnub Jan 9, 2024
0678212
lint
mohitpubnub Jan 9, 2024
1c35fe9
event engine: naming, missing transitions, handling `reconnect` and `…
mohitpubnub Jan 11, 2024
7723146
event engine: receiving state as per specifications
mohitpubnub Jan 11, 2024
29343c1
refined naming for event engine events and effects
mohitpubnub Jan 11, 2024
f4c7f15
retryConfiguration behaviour updates
mohitpubnub Jan 11, 2024
9a07850
presence eventengine: removed unnecessary emitStatus events as per sp…
mohitpubnub Jan 11, 2024
e03d14d
config naming convention, eventengine initialisation updates as per n…
mohitpubnub Jan 11, 2024
41383dc
updated tests
mohitpubnub Jan 11, 2024
aab7eae
dist, lib and lint fixes
mohitpubnub Jan 11, 2024
c35559f
package-lock dependabot suggestion, fix test
mohitpubnub Jan 11, 2024
b4db5b5
removed duplicate file
mohitpubnub Jan 11, 2024
f46818f
fix: prevent duplicate listener to be added.
mohitpubnub Jan 12, 2024
5389aaf
dist/lib files
mohitpubnub Jan 12, 2024
1bdda1f
retry delay can be override by retry after value
mohitpubnub Jan 14, 2024
1f050fb
handled cursor across the states
mohitpubnub Jan 14, 2024
d2b2809
manage cursor from event struct
mohitpubnub Jan 14, 2024
aa306aa
dist and lib
mohitpubnub Jan 14, 2024
a428e1e
refactor: reconnect event handling
mohitpubnub Jan 15, 2024
d5e88d7
getSubscribedChannels and channelGroups binding when eventEngine is e…
mohitpubnub Jan 15, 2024
82e6438
refactor: retry policy delay calculation
mohitpubnub Jan 15, 2024
79fd10b
handshake* states: handling cursor value across state and defaulting …
mohitpubnub Jan 15, 2024
1117a84
receiv* states: handling cursor across states
mohitpubnub Jan 15, 2024
0d4a6f3
lib/dist
mohitpubnub Jan 15, 2024
594b5c9
addressed review comments : handling cursor value from context from h…
mohitpubnub Jan 15, 2024
b7aaf7d
revert test file changes
mohitpubnub Jan 15, 2024
ea443b6
fix: lint
mohitpubnub Jan 15, 2024
ed83cab
sync package-lock
mohitpubnub Jan 16, 2024
f815ad8
removed flow_interfaces reference
mohitpubnub Jan 16, 2024
e93db09
PubNub SDK v7.5.0 release.
pubnub-release-bot Jan 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 25 additions & 5 deletions src/event-engine/core/retryPolicy.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
export class RetryPolicy {
static excludedErrorCodes = [403, 429];
static LinearRetryPolicy(configuration: LinearRetryPolicyConfiguration) {
return {
delay: configuration.delay,
maximumRetry: configuration.maximumRetry,
shouldRetry(error: any, attempt: number) {
if (error?.status?.statusCode === 403) {
if (RetryPolicy.excludedErrorCodes.includes(error?.status?.statusCode)) {
parfeon marked this conversation as resolved.
Show resolved Hide resolved
return false;
}
return this.maximumRetry > attempt;
},
getDelay(_: number) {
return this.delay * 1000;
return (this.delay + Math.random()) * 1000;
},
getGiveupReason(error: any, attempt: number) {
if (this.maximumRetry <= attempt) {
return 'retry attempts exhaused.';
}
if (RetryPolicy.excludedErrorCodes.includes(error?.status?.statusCode)) {
return 'forbidden or too many requests.';
}
return 'unknown error';
},
};
}
Expand All @@ -29,13 +39,23 @@ export class RetryPolicy {
},

getDelay(attempt: number) {
const calculatedDelay = Math.trunc(Math.pow(2, attempt)) * 1000 + Math.random() * 1000;
if (calculatedDelay > 150000) {
return 150000;
const calculatedDelay = (Math.pow(2, attempt) + Math.random()) * 1000;
if (calculatedDelay > this.maximumDelay) {
return this.maximumDelay;
} else {
return calculatedDelay;
}
},

getGiveupReason(error: any, attempt: number) {
if (this.maximumRetry <= attempt) {
return 'retry attempts exhaused.';
}
if (RetryPolicy.excludedErrorCodes.includes(error?.status?.statusCode)) {
return 'forbidden or too many requests.';
}
return 'unknown error';
},
};
}
}
Expand Down