Skip to content

Commit

Permalink
Merge branch 'feat/presence-event-engine' into feat/presence-api
Browse files Browse the repository at this point in the history
  • Loading branch information
Xavrax committed Aug 28, 2023
2 parents 0f67feb + ee7958a commit 0aa9c0e
Show file tree
Hide file tree
Showing 41 changed files with 2,006 additions and 1,363 deletions.
12 changes: 6 additions & 6 deletions src/core/event_engine/effect_dispatcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ where
log::debug!("Received invocation: {}", invocation.id());

let effect = cloned_self.dispatch(&invocation);
let task_completition = completion.clone();
let task_completion = completion.clone();

if let Some(effect) = effect {
log::debug!("Dispatched effect: {}", effect.id());
Expand All @@ -86,7 +86,7 @@ where
cloned_self.remove_managed_effect(effect.id());
}

task_completition(events);
task_completion(events);
});
}
}
Expand Down Expand Up @@ -260,7 +260,7 @@ mod should {
"Non managed effects shouldn't be stored"
);

assert!(effect.unwrap().id() == "EFFECT_ONE");
assert_eq!(effect.unwrap().id(), "EFFECT_ONE");
}

#[tokio::test]
Expand All @@ -275,22 +275,22 @@ mod should {
"Managed effect should be removed on completion"
);

assert!(effect.unwrap().id() == "EFFECT_TWO");
assert_eq!(effect.unwrap().id(), "EFFECT_TWO");
}

#[test]
fn cancel_managed_effect() {
let (_tx, rx) = async_channel::bounded::<TestInvocation>(5);
let dispatcher = Arc::new(EffectDispatcher::new(TestEffectHandler {}, rx));
dispatcher.dispatch(&TestInvocation::Three);
let cancelation_effect = dispatcher.dispatch(&TestInvocation::CancelThree);
let cancellation_effect = dispatcher.dispatch(&TestInvocation::CancelThree);

assert_eq!(
dispatcher.managed.read().len(),
0,
"Managed effect should be cancelled"
);

assert!(cancelation_effect.is_none());
assert!(cancellation_effect.is_none());
}
}
1 change: 0 additions & 1 deletion src/core/transport_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ impl TransportRequest {
.clone()
.body
.map(|bytes| {
// let deserialize_result = deserializer.deserialize(&bytes);
let deserialize_result = des(&bytes);
if deserialize_result.is_err() && response.status >= 500 {
Err(PubNubError::general_api_error(
Expand Down
12 changes: 6 additions & 6 deletions src/core/utils/encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ pub enum UrlEncodeExtension {
}

/// `percent_encoding` crate recommends you to create your own set for encoding.
/// To be consistent in the whole codebase - we created a function that can be used
/// for encoding related stuff.
/// To be consistent in the whole codebase - we created a function that can be
/// used for encoding related stuff.
pub fn url_encode(data: &[u8]) -> String {
url_encode_extended(data, UrlEncodeExtension::Default).to_string()
}

/// `percent_encoding` crate recommends you to create your own set for encoding.
/// To be consistent in the whole codebase - we created a function that can be used
/// for encoding related stuff.
/// To be consistent in the whole codebase - we created a function that can be
/// used for encoding related stuff.
pub fn url_encode_extended(data: &[u8], extension: UrlEncodeExtension) -> String {
let set = match extension {
UrlEncodeExtension::Default => PUBNUB_SET,
Expand Down Expand Up @@ -74,7 +74,7 @@ pub fn join_url_encoded(strings: &[&str], sep: &str) -> Option<String> {
/// URL-encode channels list.
///
/// Channels list used as part of URL path and therefore required.
#[cfg(all(any(feature = "subscribe", feature = "presence"), feature = "std"))]
#[cfg(any(feature = "subscribe", feature = "presence"))]
pub(crate) fn url_encoded_channels(channels: &[String]) -> String {
join_url_encoded(
channels
Expand All @@ -88,7 +88,7 @@ pub(crate) fn url_encoded_channels(channels: &[String]) -> String {
}

/// URL-encode channel groups list.
#[cfg(all(any(feature = "subscribe", feature = "presence"), feature = "std"))]
#[cfg(any(feature = "subscribe", feature = "presence"))]
pub(crate) fn url_encoded_channel_groups(channel_groups: &[String]) -> Option<String> {
join_url_encoded(
channel_groups
Expand Down
14 changes: 12 additions & 2 deletions src/core/utils/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
#[cfg(any(feature = "publish", feature = "access", feature = "subscribe"))]
#[cfg(any(
feature = "publish",
feature = "access",
feature = "subscribe",
feature = "presence"
))]
pub mod encoding;
#[cfg(any(feature = "publish", feature = "access", feature = "subscribe"))]
#[cfg(any(
feature = "publish",
feature = "access",
feature = "subscribe",
feature = "presence"
))]
pub mod headers;

pub mod metadata;
2 changes: 2 additions & 0 deletions src/dx/access/builders/grant_token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ where
S: for<'se, 'rq> Serializer<'se, GrantTokenPayload<'rq>>,
{
/// Current client which can provide transportation to perform the request.
///
/// This field is used to get [`Transport`] to perform the request.
#[builder(field(vis = "pub(in crate::dx::access)"), setter(custom))]
pub(in crate::dx::access) pubnub_client: PubNubClientInstance<T, D>,

Expand Down
2 changes: 2 additions & 0 deletions src/dx/access/builders/revoke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ use derive_builder::Builder;
/// [`PubNubClient`]: crate::PubNubClient
pub struct RevokeTokenRequest<T, D> {
/// Current client which can provide transportation to perform the request.
///
/// This field is used to get [`Transport`] to perform the request.
#[builder(field(vis = "pub(in crate::dx::access)"), setter(custom))]
pub(in crate::dx::access) pubnub_client: PubNubClientInstance<T, D>,

Expand Down
Loading

0 comments on commit 0aa9c0e

Please sign in to comment.