Skip to content

Commit

Permalink
Subscription Event Engine and Events Listener implementation (#196)
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
parfeon and pubnub-release-bot authored Oct 15, 2024
1 parent a1bb8bb commit dab23a6
Show file tree
Hide file tree
Showing 85 changed files with 13,916 additions and 83 deletions.
4 changes: 2 additions & 2 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ PenaltyExcessCharacter: 4
PenaltyReturnTypeOnItsOwnLine: 100
PointerAlignment: Left
ReflowComments: true
SortIncludes: false
SortIncludes: Never
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: true
Expand All @@ -101,7 +101,7 @@ SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
Standard: c++11
TabWidth: 4
UseTab: Never
...
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ jobs:
runner:
- os: ubuntu-latest
group: Default
- os: macos-13
group: macos-gh
# - os: macos-13
# group: macos-gh
steps:
- name: Checkout project
uses: actions/checkout@v3
Expand Down
31 changes: 23 additions & 8 deletions .pubnub.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,23 @@
name: c-core
schema: 1
version: "4.13.1"
version: "4.14.0"
scm: github.com/pubnub/c-core
changelog:
- date: 2024-10-15
version: v4.14.0
changes:
- type: feature
text: "Add core Event Engine implementation with the required set of types and methods."
- type: feature
text: "Add Subscribe Event Engine built atop of the core Event Engine implementation."
- type: feature
text: "Add the following entities: channel, channel group, uuid and channel metadata objects."
- type: feature
text: "Add objects to manage subscriptions and provides interface for update listeners."
- type: feature
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)."
- type: feature
text: "Added ability to configure automated retry policies for failed requests."
- date: 2024-09-05
version: v4.13.1
changes:
Expand Down Expand Up @@ -853,7 +868,7 @@ sdks:
distribution-type: source code
distribution-repository: GitHub release
package-name: C-Core
location: https://github.com/pubnub/c-core/releases/tag/v4.13.1
location: https://github.com/pubnub/c-core/releases/tag/v4.14.0
requires:
-
name: "miniz"
Expand Down Expand Up @@ -919,7 +934,7 @@ sdks:
distribution-type: source code
distribution-repository: GitHub release
package-name: C-Core
location: https://github.com/pubnub/c-core/releases/tag/v4.13.1
location: https://github.com/pubnub/c-core/releases/tag/v4.14.0
requires:
-
name: "miniz"
Expand Down Expand Up @@ -985,7 +1000,7 @@ sdks:
distribution-type: source code
distribution-repository: GitHub release
package-name: C-Core
location: https://github.com/pubnub/c-core/releases/tag/v4.13.1
location: https://github.com/pubnub/c-core/releases/tag/v4.14.0
requires:
-
name: "miniz"
Expand Down Expand Up @@ -1047,7 +1062,7 @@ sdks:
distribution-type: source code
distribution-repository: GitHub release
package-name: C-Core
location: https://github.com/pubnub/c-core/releases/tag/v4.13.1
location: https://github.com/pubnub/c-core/releases/tag/v4.14.0
requires:
-
name: "miniz"
Expand Down Expand Up @@ -1108,7 +1123,7 @@ sdks:
distribution-type: source code
distribution-repository: GitHub release
package-name: C-Core
location: https://github.com/pubnub/c-core/releases/tag/v4.13.1
location: https://github.com/pubnub/c-core/releases/tag/v4.14.0
requires:
-
name: "miniz"
Expand Down Expand Up @@ -1164,7 +1179,7 @@ sdks:
distribution-type: source code
distribution-repository: GitHub release
package-name: C-Core
location: https://github.com/pubnub/c-core/releases/tag/v4.13.1
location: https://github.com/pubnub/c-core/releases/tag/v4.14.0
requires:
-
name: "miniz"
Expand Down Expand Up @@ -1217,7 +1232,7 @@ sdks:
distribution-type: source code
distribution-repository: GitHub release
package-name: C-Core
location: https://github.com/pubnub/c-core/releases/tag/v4.13.1
location: https://github.com/pubnub/c-core/releases/tag/v4.14.0
requires:
-
name: "miniz"
Expand Down
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
## v4.14.0
October 15 2024

#### Added
- Add core Event Engine implementation with the required set of types and methods.
- Add Subscribe Event Engine built atop of the core Event Engine implementation.
- Add the following entities: channel, channel group, uuid and channel metadata objects.
- Add objects to manage subscriptions and provides interface for update listeners.
- Add new event listeners, which make it possible to add listeners to a specific entity or group of entities (though subscription and subscription set).
- Added ability to configure automated retry policies for failed requests.

## v4.13.1
September 05 2024

Expand Down
59 changes: 52 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ num_option(ONLY_PUBSUB_API "Only pubsub API" OFF)
num_option(USE_PROXY "Use proxy" ON)
num_option(USE_GZIP_COMPRESSION "Use gzip compression" ON)
num_option(RECEIVE_GZIP_RESPONSE "Use gzip decompression" ON)
num_option(USE_RETRY_CONFIGURATION "Use requests retry" OFF)
num_option(USE_SUBSCRIBE_V2 "Use subscribe v2" ON)
num_option(USE_SUBSCRIBE_EVENT_ENGINE "Use Subscribe Event Engine" OFF)
num_option(USE_ADVANCED_HISTORY "Use advanced history" ON)
num_option(USE_OBJECTS_API "Use objects API" ON)
num_option(USE_AUTO_HEARTBEAT "Use auto heartbeat" ON)
Expand Down Expand Up @@ -97,13 +99,16 @@ set(FLAGS "\
-D PUBNUB_PROXY_API=${USE_PROXY} \
-D PUBNUB_USE_GZIP_COMPRESSION=${USE_GZIP_COMPRESSION} \
-D PUBNUB_RECEIVE_GZIP_RESPONSE=${RECEIVE_GZIP_RESPONSE} \
-D PUBNUB_USE_RETRY_CONFIGURATION=${USE_RETRY_CONFIGURATION} \
-D PUBNUB_USE_SUBSCRIBE_V2=${USE_SUBSCRIBE_V2} \
-D PUBNUB_USE_SUBSCRIBE_EVENT_ENGINE=${USE_SUBSCRIBE_EVENT_ENGINE} \
-D PUBNUB_USE_OBJECTS_API=${USE_OBJECTS_API} \
-D PUBNUB_USE_ACTIONS_API=${USE_ACTIONS_API} \
-D PUBNUB_USE_AUTO_HEARTBEAT=${USE_AUTO_HEARTBEAT} \
-D PUBNUB_USE_GRANT_TOKEN_API=${USE_GRANT_TOKEN_API} \
-D PUBNUB_USE_REVOKE_TOKEN_API=${USE_REVOKE_TOKEN_API} \
-D PUBNUB_USE_FETCH_HISTORY=${USE_FETCH_HISTORY} \
-D PUBNUB_CRYPTO_API=${USE_CRYPTO_API} \
-D PUBNUB_RAND_INIT_VECTOR=${USE_LEGACY_CRYPTO_RANDOM_IV} \
-D PUBNUB_MBEDTLS=${MBEDTLS}")

Expand Down Expand Up @@ -324,13 +329,43 @@ if(${RECEIVE_GZIP_RESPONSE})
${CMAKE_CURRENT_LIST_DIR}/core/pbgzip_decompress.c)
endif()

if(${USE_SUBSCRIBE_V2})
if (${USE_RETRY_CONFIGURATION})
set(FEATURE_SOURCEFILES
${FEATURE_SOURCEFILES}
${CMAKE_CURRENT_LIST_DIR}/core/pbcc_request_retry_timer.c
${CMAKE_CURRENT_LIST_DIR}/core/pubnub_retry_configuration.c)
endif ()

if(${USE_SUBSCRIBE_V2})
set(FEATURE_SOURCEFILES
${FEATURE_SOURCEFILES}
${CMAKE_CURRENT_LIST_DIR}/core/pbcc_subscribe_v2.c
${CMAKE_CURRENT_LIST_DIR}/core/pubnub_subscribe_v2.c)
endif()

if(${USE_SUBSCRIBE_EVENT_ENGINE})
message(STATUS "Using subscribe event engine API")
set(LIB_SOURCEFILES
${LIB_SOURCEFILES}
${CMAKE_CURRENT_LIST_DIR}/lib/pbarray.c
${CMAKE_CURRENT_LIST_DIR}/lib/pbhash_set.c
${CMAKE_CURRENT_LIST_DIR}/lib/pbref_counter.c
${CMAKE_CURRENT_LIST_DIR}/lib/pbstrdup.c)
set(FEATURE_SOURCEFILES
${FEATURE_SOURCEFILES}
${CMAKE_CURRENT_LIST_DIR}/core/pbcc_memory_utils.c
${CMAKE_CURRENT_LIST_DIR}/core/pbcc_event_engine.c
${CMAKE_CURRENT_LIST_DIR}/core/pbcc_subscribe_event_engine.c
${CMAKE_CURRENT_LIST_DIR}/core/pbcc_subscribe_event_engine_states.c
${CMAKE_CURRENT_LIST_DIR}/core/pbcc_subscribe_event_engine_events.c
${CMAKE_CURRENT_LIST_DIR}/core/pbcc_subscribe_event_engine_effects.c
${CMAKE_CURRENT_LIST_DIR}/core/pbcc_subscribe_event_engine_transitions.c
${CMAKE_CURRENT_LIST_DIR}/core/pbcc_subscribe_event_listener.c
${CMAKE_CURRENT_LIST_DIR}/core/pubnub_entities.c
${CMAKE_CURRENT_LIST_DIR}/core/pubnub_subscribe_event_engine.c
${CMAKE_CURRENT_LIST_DIR}/core/pubnub_subscribe_event_listener.c)
endif()

if(${USE_ADVANCED_HISTORY})
set(FEATURE_SOURCEFILES
${FEATURE_SOURCEFILES}
Expand Down Expand Up @@ -440,12 +475,7 @@ if(${OPENSSL})
set(FEATURE_SOURCEFILES
${CMAKE_CURRENT_LIST_DIR}/openssl/pbpal_openssl.c
${CMAKE_CURRENT_LIST_DIR}/openssl/pbpal_connect_openssl.c
${CMAKE_CURRENT_LIST_DIR}/openssl/pbpal_openssl_blocking_io.c
${CMAKE_CURRENT_LIST_DIR}/core/pbcc_crypto.c
${CMAKE_CURRENT_LIST_DIR}/core/pbcc_crypto_aes_cbc.c
${CMAKE_CURRENT_LIST_DIR}/core/pbcc_crypto_legacy.c
${CMAKE_CURRENT_LIST_DIR}/core/pubnub_crypto.c
${CMAKE_CURRENT_LIST_DIR}/openssl/pbaes256.c
${CMAKE_CURRENT_LIST_DIR}/openssl/pbpal_openssl_blocking_io.c
${FEATURE_SOURCEFILES})

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

set(LDLIBS ${LDLIBS})

if(USE_CRYPTO_API)
set(FEATURE_SOURCEFILES
${CMAKE_CURRENT_LIST_DIR}/core/pbcc_crypto.c
${CMAKE_CURRENT_LIST_DIR}/core/pbcc_crypto_aes_cbc.c
${CMAKE_CURRENT_LIST_DIR}/core/pbcc_crypto_legacy.c
${CMAKE_CURRENT_LIST_DIR}/core/pubnub_crypto.c
${CMAKE_CURRENT_LIST_DIR}/openssl/pbaes256.c
${FEATURE_SOURCEFILES})
endif()

if(UNIX)
set(FEATURE_SOURCEFILES ${FEATURE_SOURCEFILES} ${CMAKE_CURRENT_LIST_DIR}/openssl/pbpal_add_system_certs_posix.c)
elseif(WIN32 OR WIN64 OR MSVC)
Expand Down Expand Up @@ -669,6 +709,11 @@ if(${EXAMPLES})
subscribe_publish_from_callback
publish_callback_subloop_sample
publish_queue_callback_subloop)
if(${USE_SUBSCRIBE_EVENT_ENGINE})
set(EXAMPLE_LIST
subscribe_event_engine_sample
${EXAMPLE_LIST})
endif()
if (WITH_CPP)
set(CPP_EXAMPLE_LIST
subscribe_publish_callback_sample # Only supports callback!
Expand Down
1 change: 0 additions & 1 deletion core/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ pubnub_subscribe_v2_unittest: $(PROJECT_SOURCEFILES) $(SUBSCRIBE_V2_SOURCEFILES)
$(CGREEN_RUNNER) ./pubnub_subscribe_v2_unit_test.so
#$(GCOVR) -r . --html --html-details -o coverage.html


clean:
find . -type d -iname "*.dSYM" -exec rm -rf {} \+
find . -type f -name "*.so" -o -name "*.gcda" -o -name "*.gcno" -o -name "*.html" | xargs -r rm -rf
Expand Down
1 change: 1 addition & 0 deletions core/pbauto_heartbeat.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ static int copy_context_settings(pubnub_t* pb_clone, pubnub_t const* pb)
PUBNUB_ASSERT_OPT(pb_valid_ctx_ptr(pb));

pubnub_mutex_lock(pb_clone->monitor);
pb_clone->core.auth_token = pb->core.auth_token;
pb_clone->core.auth = pb->core.auth;
strcpy(pb_clone->core.user_id, pb->core.user_id);
if (PUBNUB_ORIGIN_SETTABLE) {
Expand Down
2 changes: 1 addition & 1 deletion core/pbcc_crypto.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#ifndef PBCC_CRYPTO_H
#define PBCC_CRYPTO_H
#if PUBNUB_CRYPTO_API

/** @file pbcc_crypto.h
Expand Down Expand Up @@ -294,7 +295,6 @@ void pbcc_set_crypto_module(struct pbcc_context *ctx, struct pubnub_crypto_provi
*/
pubnub_crypto_provider_t *pbcc_get_crypto_module(struct pbcc_context *ctx);

#if PUBNUB_CRYPTO_API
/**
Decrypt the message received from PubNub with the crypto module.
Expand Down
Loading

0 comments on commit dab23a6

Please sign in to comment.