Skip to content

Commit dab23a6

Browse files
Subscription Event Engine and Events Listener implementation (#196)
feat(event-engine): add general event engine Add core Event Engine implementation with required set of types and methods. feat(subscribe-event-engine): add subscribe event engine Add Subscribe Event Engine built atop of core Event Engine implementation. feat(entities): add base PubNub entities Add following entities: channel, channel group, uuid and channel metadata objects. feat(subscription): add subscription and subscription sets Add objects to manage subscription and provides interface fow updated listeners. feat(listeners): add event listener Add new event listeners which make it possible to add listeners to specific entity or group of entities (though subscription and subscription set). feat(retry): add retry policy Add failed request automated retry configuration and timer implementations. fix(subscribe): fix `matched` field parse in subscribe response Fixed issue because of which `matched` field had wrong value and length. * fix(auto-heartbeat): memory issues with member removal Fix issues because of which library crashes in attempt to move memory into overlapping region. --------- Co-authored-by: PubNub Release Bot <[email protected]>
1 parent a1bb8bb commit dab23a6

File tree

85 files changed

+13916
-83
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+13916
-83
lines changed

.clang-format

+2-2
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ PenaltyExcessCharacter: 4
8888
PenaltyReturnTypeOnItsOwnLine: 100
8989
PointerAlignment: Left
9090
ReflowComments: true
91-
SortIncludes: false
91+
SortIncludes: Never
9292
SortUsingDeclarations: true
9393
SpaceAfterCStyleCast: false
9494
SpaceAfterTemplateKeyword: true
@@ -101,7 +101,7 @@ SpacesInContainerLiterals: true
101101
SpacesInCStyleCastParentheses: false
102102
SpacesInParentheses: false
103103
SpacesInSquareBrackets: false
104-
Standard: Cpp11
104+
Standard: c++11
105105
TabWidth: 4
106106
UseTab: Never
107107
...

.github/workflows/run-tests.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ jobs:
2121
runner:
2222
- os: ubuntu-latest
2323
group: Default
24-
- os: macos-13
25-
group: macos-gh
24+
# - os: macos-13
25+
# group: macos-gh
2626
steps:
2727
- name: Checkout project
2828
uses: actions/checkout@v3

.pubnub.yml

+23-8
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,23 @@
11
name: c-core
22
schema: 1
3-
version: "4.13.1"
3+
version: "4.14.0"
44
scm: github.com/pubnub/c-core
55
changelog:
6+
- date: 2024-10-15
7+
version: v4.14.0
8+
changes:
9+
- type: feature
10+
text: "Add core Event Engine implementation with the required set of types and methods."
11+
- type: feature
12+
text: "Add Subscribe Event Engine built atop of the core Event Engine implementation."
13+
- type: feature
14+
text: "Add the following entities: channel, channel group, uuid and channel metadata objects."
15+
- type: feature
16+
text: "Add objects to manage subscriptions and provides interface for update listeners."
17+
- type: feature
18+
text: "Add new event listeners, which make it possible to add listeners to a specific entity or group of entities (though subscription and subscription set)."
19+
- type: feature
20+
text: "Added ability to configure automated retry policies for failed requests."
621
- date: 2024-09-05
722
version: v4.13.1
823
changes:
@@ -853,7 +868,7 @@ sdks:
853868
distribution-type: source code
854869
distribution-repository: GitHub release
855870
package-name: C-Core
856-
location: https://github.com/pubnub/c-core/releases/tag/v4.13.1
871+
location: https://github.com/pubnub/c-core/releases/tag/v4.14.0
857872
requires:
858873
-
859874
name: "miniz"
@@ -919,7 +934,7 @@ sdks:
919934
distribution-type: source code
920935
distribution-repository: GitHub release
921936
package-name: C-Core
922-
location: https://github.com/pubnub/c-core/releases/tag/v4.13.1
937+
location: https://github.com/pubnub/c-core/releases/tag/v4.14.0
923938
requires:
924939
-
925940
name: "miniz"
@@ -985,7 +1000,7 @@ sdks:
9851000
distribution-type: source code
9861001
distribution-repository: GitHub release
9871002
package-name: C-Core
988-
location: https://github.com/pubnub/c-core/releases/tag/v4.13.1
1003+
location: https://github.com/pubnub/c-core/releases/tag/v4.14.0
9891004
requires:
9901005
-
9911006
name: "miniz"
@@ -1047,7 +1062,7 @@ sdks:
10471062
distribution-type: source code
10481063
distribution-repository: GitHub release
10491064
package-name: C-Core
1050-
location: https://github.com/pubnub/c-core/releases/tag/v4.13.1
1065+
location: https://github.com/pubnub/c-core/releases/tag/v4.14.0
10511066
requires:
10521067
-
10531068
name: "miniz"
@@ -1108,7 +1123,7 @@ sdks:
11081123
distribution-type: source code
11091124
distribution-repository: GitHub release
11101125
package-name: C-Core
1111-
location: https://github.com/pubnub/c-core/releases/tag/v4.13.1
1126+
location: https://github.com/pubnub/c-core/releases/tag/v4.14.0
11121127
requires:
11131128
-
11141129
name: "miniz"
@@ -1164,7 +1179,7 @@ sdks:
11641179
distribution-type: source code
11651180
distribution-repository: GitHub release
11661181
package-name: C-Core
1167-
location: https://github.com/pubnub/c-core/releases/tag/v4.13.1
1182+
location: https://github.com/pubnub/c-core/releases/tag/v4.14.0
11681183
requires:
11691184
-
11701185
name: "miniz"
@@ -1217,7 +1232,7 @@ sdks:
12171232
distribution-type: source code
12181233
distribution-repository: GitHub release
12191234
package-name: C-Core
1220-
location: https://github.com/pubnub/c-core/releases/tag/v4.13.1
1235+
location: https://github.com/pubnub/c-core/releases/tag/v4.14.0
12211236
requires:
12221237
-
12231238
name: "miniz"

CHANGELOG.md

+11
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
## v4.14.0
2+
October 15 2024
3+
4+
#### Added
5+
- Add core Event Engine implementation with the required set of types and methods.
6+
- Add Subscribe Event Engine built atop of the core Event Engine implementation.
7+
- Add the following entities: channel, channel group, uuid and channel metadata objects.
8+
- Add objects to manage subscriptions and provides interface for update listeners.
9+
- Add new event listeners, which make it possible to add listeners to a specific entity or group of entities (though subscription and subscription set).
10+
- Added ability to configure automated retry policies for failed requests.
11+
112
## v4.13.1
213
September 05 2024
314

CMakeLists.txt

+52-7
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ num_option(ONLY_PUBSUB_API "Only pubsub API" OFF)
6060
num_option(USE_PROXY "Use proxy" ON)
6161
num_option(USE_GZIP_COMPRESSION "Use gzip compression" ON)
6262
num_option(RECEIVE_GZIP_RESPONSE "Use gzip decompression" ON)
63+
num_option(USE_RETRY_CONFIGURATION "Use requests retry" OFF)
6364
num_option(USE_SUBSCRIBE_V2 "Use subscribe v2" ON)
65+
num_option(USE_SUBSCRIBE_EVENT_ENGINE "Use Subscribe Event Engine" OFF)
6466
num_option(USE_ADVANCED_HISTORY "Use advanced history" ON)
6567
num_option(USE_OBJECTS_API "Use objects API" ON)
6668
num_option(USE_AUTO_HEARTBEAT "Use auto heartbeat" ON)
@@ -97,13 +99,16 @@ set(FLAGS "\
9799
-D PUBNUB_PROXY_API=${USE_PROXY} \
98100
-D PUBNUB_USE_GZIP_COMPRESSION=${USE_GZIP_COMPRESSION} \
99101
-D PUBNUB_RECEIVE_GZIP_RESPONSE=${RECEIVE_GZIP_RESPONSE} \
102+
-D PUBNUB_USE_RETRY_CONFIGURATION=${USE_RETRY_CONFIGURATION} \
100103
-D PUBNUB_USE_SUBSCRIBE_V2=${USE_SUBSCRIBE_V2} \
104+
-D PUBNUB_USE_SUBSCRIBE_EVENT_ENGINE=${USE_SUBSCRIBE_EVENT_ENGINE} \
101105
-D PUBNUB_USE_OBJECTS_API=${USE_OBJECTS_API} \
102106
-D PUBNUB_USE_ACTIONS_API=${USE_ACTIONS_API} \
103107
-D PUBNUB_USE_AUTO_HEARTBEAT=${USE_AUTO_HEARTBEAT} \
104108
-D PUBNUB_USE_GRANT_TOKEN_API=${USE_GRANT_TOKEN_API} \
105109
-D PUBNUB_USE_REVOKE_TOKEN_API=${USE_REVOKE_TOKEN_API} \
106110
-D PUBNUB_USE_FETCH_HISTORY=${USE_FETCH_HISTORY} \
111+
-D PUBNUB_CRYPTO_API=${USE_CRYPTO_API} \
107112
-D PUBNUB_RAND_INIT_VECTOR=${USE_LEGACY_CRYPTO_RANDOM_IV} \
108113
-D PUBNUB_MBEDTLS=${MBEDTLS}")
109114

@@ -324,13 +329,43 @@ if(${RECEIVE_GZIP_RESPONSE})
324329
${CMAKE_CURRENT_LIST_DIR}/core/pbgzip_decompress.c)
325330
endif()
326331

327-
if(${USE_SUBSCRIBE_V2})
332+
if (${USE_RETRY_CONFIGURATION})
328333
set(FEATURE_SOURCEFILES
334+
${FEATURE_SOURCEFILES}
335+
${CMAKE_CURRENT_LIST_DIR}/core/pbcc_request_retry_timer.c
336+
${CMAKE_CURRENT_LIST_DIR}/core/pubnub_retry_configuration.c)
337+
endif ()
338+
339+
if(${USE_SUBSCRIBE_V2})
340+
set(FEATURE_SOURCEFILES
329341
${FEATURE_SOURCEFILES}
330342
${CMAKE_CURRENT_LIST_DIR}/core/pbcc_subscribe_v2.c
331343
${CMAKE_CURRENT_LIST_DIR}/core/pubnub_subscribe_v2.c)
332344
endif()
333345

346+
if(${USE_SUBSCRIBE_EVENT_ENGINE})
347+
message(STATUS "Using subscribe event engine API")
348+
set(LIB_SOURCEFILES
349+
${LIB_SOURCEFILES}
350+
${CMAKE_CURRENT_LIST_DIR}/lib/pbarray.c
351+
${CMAKE_CURRENT_LIST_DIR}/lib/pbhash_set.c
352+
${CMAKE_CURRENT_LIST_DIR}/lib/pbref_counter.c
353+
${CMAKE_CURRENT_LIST_DIR}/lib/pbstrdup.c)
354+
set(FEATURE_SOURCEFILES
355+
${FEATURE_SOURCEFILES}
356+
${CMAKE_CURRENT_LIST_DIR}/core/pbcc_memory_utils.c
357+
${CMAKE_CURRENT_LIST_DIR}/core/pbcc_event_engine.c
358+
${CMAKE_CURRENT_LIST_DIR}/core/pbcc_subscribe_event_engine.c
359+
${CMAKE_CURRENT_LIST_DIR}/core/pbcc_subscribe_event_engine_states.c
360+
${CMAKE_CURRENT_LIST_DIR}/core/pbcc_subscribe_event_engine_events.c
361+
${CMAKE_CURRENT_LIST_DIR}/core/pbcc_subscribe_event_engine_effects.c
362+
${CMAKE_CURRENT_LIST_DIR}/core/pbcc_subscribe_event_engine_transitions.c
363+
${CMAKE_CURRENT_LIST_DIR}/core/pbcc_subscribe_event_listener.c
364+
${CMAKE_CURRENT_LIST_DIR}/core/pubnub_entities.c
365+
${CMAKE_CURRENT_LIST_DIR}/core/pubnub_subscribe_event_engine.c
366+
${CMAKE_CURRENT_LIST_DIR}/core/pubnub_subscribe_event_listener.c)
367+
endif()
368+
334369
if(${USE_ADVANCED_HISTORY})
335370
set(FEATURE_SOURCEFILES
336371
${FEATURE_SOURCEFILES}
@@ -440,12 +475,7 @@ if(${OPENSSL})
440475
set(FEATURE_SOURCEFILES
441476
${CMAKE_CURRENT_LIST_DIR}/openssl/pbpal_openssl.c
442477
${CMAKE_CURRENT_LIST_DIR}/openssl/pbpal_connect_openssl.c
443-
${CMAKE_CURRENT_LIST_DIR}/openssl/pbpal_openssl_blocking_io.c
444-
${CMAKE_CURRENT_LIST_DIR}/core/pbcc_crypto.c
445-
${CMAKE_CURRENT_LIST_DIR}/core/pbcc_crypto_aes_cbc.c
446-
${CMAKE_CURRENT_LIST_DIR}/core/pbcc_crypto_legacy.c
447-
${CMAKE_CURRENT_LIST_DIR}/core/pubnub_crypto.c
448-
${CMAKE_CURRENT_LIST_DIR}/openssl/pbaes256.c
478+
${CMAKE_CURRENT_LIST_DIR}/openssl/pbpal_openssl_blocking_io.c
449479
${FEATURE_SOURCEFILES})
450480

451481
set(FEATURE_SOURCEFILES
@@ -454,6 +484,16 @@ if(${OPENSSL})
454484

455485
set(LDLIBS ${LDLIBS})
456486

487+
if(USE_CRYPTO_API)
488+
set(FEATURE_SOURCEFILES
489+
${CMAKE_CURRENT_LIST_DIR}/core/pbcc_crypto.c
490+
${CMAKE_CURRENT_LIST_DIR}/core/pbcc_crypto_aes_cbc.c
491+
${CMAKE_CURRENT_LIST_DIR}/core/pbcc_crypto_legacy.c
492+
${CMAKE_CURRENT_LIST_DIR}/core/pubnub_crypto.c
493+
${CMAKE_CURRENT_LIST_DIR}/openssl/pbaes256.c
494+
${FEATURE_SOURCEFILES})
495+
endif()
496+
457497
if(UNIX)
458498
set(FEATURE_SOURCEFILES ${FEATURE_SOURCEFILES} ${CMAKE_CURRENT_LIST_DIR}/openssl/pbpal_add_system_certs_posix.c)
459499
elseif(WIN32 OR WIN64 OR MSVC)
@@ -669,6 +709,11 @@ if(${EXAMPLES})
669709
subscribe_publish_from_callback
670710
publish_callback_subloop_sample
671711
publish_queue_callback_subloop)
712+
if(${USE_SUBSCRIBE_EVENT_ENGINE})
713+
set(EXAMPLE_LIST
714+
subscribe_event_engine_sample
715+
${EXAMPLE_LIST})
716+
endif()
672717
if (WITH_CPP)
673718
set(CPP_EXAMPLE_LIST
674719
subscribe_publish_callback_sample # Only supports callback!

core/Makefile

-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ pubnub_subscribe_v2_unittest: $(PROJECT_SOURCEFILES) $(SUBSCRIBE_V2_SOURCEFILES)
106106
$(CGREEN_RUNNER) ./pubnub_subscribe_v2_unit_test.so
107107
#$(GCOVR) -r . --html --html-details -o coverage.html
108108

109-
110109
clean:
111110
find . -type d -iname "*.dSYM" -exec rm -rf {} \+
112111
find . -type f -name "*.so" -o -name "*.gcda" -o -name "*.gcno" -o -name "*.html" | xargs -r rm -rf

core/pbauto_heartbeat.c

+1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ static int copy_context_settings(pubnub_t* pb_clone, pubnub_t const* pb)
5959
PUBNUB_ASSERT_OPT(pb_valid_ctx_ptr(pb));
6060

6161
pubnub_mutex_lock(pb_clone->monitor);
62+
pb_clone->core.auth_token = pb->core.auth_token;
6263
pb_clone->core.auth = pb->core.auth;
6364
strcpy(pb_clone->core.user_id, pb->core.user_id);
6465
if (PUBNUB_ORIGIN_SETTABLE) {

core/pbcc_crypto.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#ifndef PBCC_CRYPTO_H
44
#define PBCC_CRYPTO_H
5+
#if PUBNUB_CRYPTO_API
56

67
/** @file pbcc_crypto.h
78
@@ -294,7 +295,6 @@ void pbcc_set_crypto_module(struct pbcc_context *ctx, struct pubnub_crypto_provi
294295
*/
295296
pubnub_crypto_provider_t *pbcc_get_crypto_module(struct pbcc_context *ctx);
296297

297-
#if PUBNUB_CRYPTO_API
298298
/**
299299
Decrypt the message received from PubNub with the crypto module.
300300

0 commit comments

Comments
 (0)