-
Notifications
You must be signed in to change notification settings - Fork 15
feat: remove internal processors + contracts #920
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
Open
brendanobra
wants to merge
3
commits into
main
Choose a base branch
from
remove-internal-processors
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1132,7 +1132,7 @@ pub mod tests { | |
| let msg = ExtnMessage { | ||
| id: "test_id".to_string(), | ||
| requestor: ExtnId::get_main_target("main".into()), | ||
| target: RippleContract::Internal, | ||
| target: RippleContract::RippleContext, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The scope of this ticket is to eliminate the use of |
||
| target_id: Some(ExtnId::get_main_target("main".into())), | ||
| payload: ExtnPayload::Response(ExtnResponse::String("success".to_string())), | ||
| ts: Some(Utc::now().timestamp_millis()), | ||
|
|
@@ -1153,7 +1153,7 @@ pub mod tests { | |
| let msg = ExtnMessage { | ||
| id: "test_id".to_string(), | ||
| requestor: ExtnId::get_main_target("main".into()), | ||
| target: RippleContract::Internal, | ||
| target: RippleContract::RippleContext, | ||
| target_id: Some(ExtnId::get_main_target("main".into())), | ||
| payload: ExtnPayload::Response(ExtnResponse::String("success".to_string())), | ||
| ts: Some(Utc::now().timestamp_millis()), | ||
|
|
@@ -1171,7 +1171,7 @@ pub mod tests { | |
| fn test_add_stream_processor() { | ||
| let extn_client = ExtnClient::mock(); | ||
| let processor = | ||
| MockRequestProcessor::new_v1(extn_client.clone(), vec![RippleContract::Internal]); | ||
| MockRequestProcessor::new_v1(extn_client.clone(), vec![RippleContract::RippleContext]); | ||
|
|
||
| add_stream_processor( | ||
| processor.contract().as_clear_string(), | ||
|
|
@@ -1186,7 +1186,7 @@ pub mod tests { | |
| fn test_add_vec_stream_processor() { | ||
| let extn_client = ExtnClient::mock(); | ||
| let processor = | ||
| MockEventProcessor::new_v1(extn_client.clone(), vec![RippleContract::Internal]); | ||
| MockEventProcessor::new_v1(extn_client.clone(), vec![RippleContract::RippleContext]); | ||
| let id = processor.contract().as_clear_string(); | ||
|
|
||
| add_vec_stream_processor( | ||
|
|
@@ -1222,7 +1222,7 @@ pub mod tests { | |
| async fn test_add_request_processor() { | ||
| let mut extn_client = ExtnClient::mock(); | ||
| let processor = | ||
| MockRequestProcessor::new_v1(extn_client.clone(), vec![RippleContract::Internal]); | ||
| MockRequestProcessor::new_v1(extn_client.clone(), vec![RippleContract::RippleContext]); | ||
|
|
||
| extn_client.add_request_processor(processor); | ||
| tokio::time::sleep(Duration::from_millis(10)).await; | ||
|
|
@@ -1242,7 +1242,7 @@ pub mod tests { | |
| async fn test_add_event_processor() { | ||
| let mut extn_client = ExtnClient::mock(); | ||
| let processor = | ||
| MockEventProcessor::new_v1(extn_client.clone(), vec![RippleContract::Internal]); | ||
| MockEventProcessor::new_v1(extn_client.clone(), vec![RippleContract::RippleContext]); | ||
| let id = processor.contract().as_clear_string(); | ||
| extn_client.add_event_processor(processor); | ||
|
|
||
|
|
@@ -1420,7 +1420,7 @@ pub mod tests { | |
| let processor = MockRequestProcessor::new_v1( | ||
| extn_client.clone(), | ||
| vec![ | ||
| RippleContract::Internal, | ||
| RippleContract::RippleContext, | ||
| RippleContract::Session(SessionAdjective::Account), | ||
| ], | ||
| ); | ||
|
|
@@ -1430,7 +1430,7 @@ pub mod tests { | |
| let response = extn_client | ||
| .request(MockRequest { | ||
| app_id: "test_app_id".to_string(), | ||
| contract: RippleContract::Internal, | ||
| contract: RippleContract::RippleContext, | ||
| expected_response: Some(ExtnResponse::Boolean(true)), | ||
| }) | ||
| .await; | ||
|
|
@@ -1440,7 +1440,7 @@ pub mod tests { | |
| let expected_message = ExtnMessage { | ||
| id: "some-uuid".to_string(), | ||
| requestor: ExtnId::get_main_target("main".into()), | ||
| target: RippleContract::Internal, | ||
| target: RippleContract::RippleContext, | ||
| target_id: None, | ||
| payload: ExtnPayload::Response(ExtnResponse::Boolean(true)), | ||
| ts: Some(Utc::now().timestamp_millis()), | ||
|
|
@@ -1467,13 +1467,13 @@ pub mod tests { | |
|
|
||
| let mut extn_client = ExtnClient::new_main(); | ||
| let processor = | ||
| MockRequestProcessor::new_v1(extn_client.clone(), vec![RippleContract::Internal]); | ||
| MockRequestProcessor::new_v1(extn_client.clone(), vec![RippleContract::RippleContext]); | ||
| extn_client.add_request_processor(processor); | ||
|
|
||
| let response = extn_client | ||
| .main_internal_request(MockRequest { | ||
| app_id: "test_app_id".to_string(), | ||
| contract: RippleContract::Internal, | ||
| contract: RippleContract::RippleContext, | ||
| expected_response: Some(ExtnResponse::Boolean(true)), | ||
| }) | ||
| .await; | ||
|
|
@@ -1483,7 +1483,7 @@ pub mod tests { | |
| let expected_message = ExtnMessage { | ||
| id: "some-uuid".to_string(), | ||
| requestor: cap, | ||
| target: RippleContract::Internal, | ||
| target: RippleContract::RippleContext, | ||
| target_id: None, | ||
| payload: ExtnPayload::Response(ExtnResponse::Boolean(true)), | ||
| ts: Some(Utc::now().timestamp_millis()), | ||
|
|
@@ -1653,7 +1653,7 @@ pub mod tests { | |
| let message = ExtnMessage { | ||
| id: "test_id".to_string(), | ||
| requestor: ExtnId::get_main_target("main".into()), | ||
| target: RippleContract::Internal, | ||
| target: RippleContract::RippleContext, | ||
| target_id: None, | ||
| payload: ExtnPayload::Request(ExtnRequest::Context( | ||
| RippleContextUpdateRequest::TimeZone(TimeZone { | ||
|
|
@@ -1679,7 +1679,7 @@ pub mod tests { | |
| async fn test_event() { | ||
| let mut extn_client = ExtnClient::new_main(); | ||
| let processor = | ||
| MockEventProcessor::new_v1(extn_client.clone(), vec![RippleContract::Internal]); | ||
| MockEventProcessor::new_v1(extn_client.clone(), vec![RippleContract::RippleContext]); | ||
|
|
||
| extn_client.add_event_processor(processor); | ||
|
|
||
|
|
@@ -1698,7 +1698,7 @@ pub mod tests { | |
| extn_client.handle_message(ExtnMessage { | ||
| id: "test_id".to_string(), | ||
| requestor: ExtnId::get_main_target("main".into()), | ||
| target: RippleContract::Internal, | ||
| target: RippleContract::RippleContext, | ||
| target_id: None, | ||
| payload: event.get_extn_payload(), | ||
| ts: Some(Utc::now().timestamp_millis()), | ||
|
|
@@ -1735,7 +1735,7 @@ pub mod tests { | |
| let mut extn_client = ExtnClient::new_main(); | ||
| let message = MockRequest { | ||
| app_id: "test_app_id".to_string(), | ||
| contract: RippleContract::Internal, | ||
| contract: RippleContract::RippleContext, | ||
| expected_response: Some(ExtnResponse::Boolean(true)), | ||
| }; | ||
| let (tx, mut rx) = mpsc::channel(1); | ||
|
|
@@ -1803,7 +1803,7 @@ pub mod tests { | |
| let msg = ExtnMessage { | ||
| id, | ||
| requestor: ExtnId::get_main_target("main".into()), | ||
| target: RippleContract::Internal, | ||
| target: RippleContract::RippleContext, | ||
| target_id: None, | ||
| payload: ExtnPayload::Response(exp_resp.clone()), | ||
| ts: Some(Utc::now().timestamp_millis()), | ||
|
|
@@ -1839,7 +1839,7 @@ pub mod tests { | |
| testing_logger::setup(); | ||
| let extn_client = ExtnClient::mock(); | ||
| let processor = | ||
| MockRequestProcessor::new_v1(extn_client.clone(), vec![RippleContract::Internal]); | ||
| MockRequestProcessor::new_v1(extn_client.clone(), vec![RippleContract::RippleContext]); | ||
|
|
||
| if tc.contains("req processor err") { | ||
| extn_client.request_processors.write().unwrap().clear(); | ||
|
|
@@ -1856,7 +1856,7 @@ pub mod tests { | |
| let msg = ExtnMessage { | ||
| id: "some-id".to_string(), | ||
| requestor: ExtnId::get_main_target("main".into()), | ||
| target: RippleContract::Internal, | ||
| target: RippleContract::RippleContext, | ||
| target_id: None, | ||
| payload: ExtnPayload::Response(exp_resp), | ||
| ts: Some(Utc::now().timestamp_millis()), | ||
|
|
@@ -1897,7 +1897,7 @@ pub mod tests { | |
| testing_logger::setup(); | ||
| let extn_client = ExtnClient::mock(); | ||
| let processor = | ||
| MockEventProcessor::new_v1(extn_client.clone(), vec![RippleContract::Internal]); | ||
| MockEventProcessor::new_v1(extn_client.clone(), vec![RippleContract::RippleContext]); | ||
| let id = processor.contract().as_clear_string(); | ||
| add_vec_stream_processor( | ||
| id.clone(), | ||
|
|
@@ -1920,7 +1920,7 @@ pub mod tests { | |
| let msg = ExtnMessage { | ||
| id: "some-id".to_string(), | ||
| requestor: ExtnId::get_main_target("main".into()), | ||
| target: RippleContract::Internal, | ||
| target: RippleContract::RippleContext, | ||
| target_id: None, | ||
| payload: ExtnPayload::Response(exp_resp), | ||
| ts: Some(Utc::now().timestamp_millis()), | ||
|
|
@@ -1953,7 +1953,7 @@ pub mod tests { | |
| let req = ExtnMessage { | ||
| id: id.clone(), | ||
| requestor: ExtnId::get_main_target("main".into()), | ||
| target: RippleContract::Internal, | ||
| target: RippleContract::RippleContext, | ||
| target_id: None, | ||
| payload: ExtnPayload::Request(ExtnRequest::Device(DeviceRequest::DeviceInfo( | ||
| DeviceInfoRequest::Model, | ||
|
|
@@ -1971,7 +1971,7 @@ pub mod tests { | |
| received_msg.requestor.to_string(), | ||
| "ripple:main:internal:main" | ||
| ); | ||
| assert_eq!(received_msg.target.as_clear_string(), "internal"); | ||
| assert_eq!(received_msg.target.as_clear_string(), "ripple_context"); | ||
| assert_eq!(received_msg.target_id, None); | ||
| if let ExtnPayload::Response(ExtnResponse::String(s)) = received_msg.payload { | ||
| assert!(s.eq("test_make")); | ||
|
|
@@ -1999,7 +1999,7 @@ pub mod tests { | |
| let msg = ExtnMessage { | ||
| id: id.clone(), | ||
| requestor: ExtnId::get_main_target("main".into()), | ||
| target: RippleContract::Internal, | ||
| target: RippleContract::RippleContext, | ||
| target_id: None, | ||
| payload: ExtnPayload::Response(ExtnResponse::String("test_make".to_string())), | ||
| ts: Some(Utc::now().timestamp_millis()), | ||
|
|
@@ -2014,7 +2014,7 @@ pub mod tests { | |
| received_msg.requestor.to_string(), | ||
| "ripple:main:internal:main" | ||
| ); | ||
| assert_eq!(received_msg.target.as_clear_string(), "internal"); | ||
| assert_eq!(received_msg.target.as_clear_string(), "ripple_context"); | ||
| assert_eq!(received_msg.target_id, None); | ||
| if let ExtnPayload::Response(ExtnResponse::String(s)) = received_msg.payload { | ||
| assert!(s.eq("test_make")); | ||
|
|
@@ -2340,15 +2340,15 @@ pub mod tests { | |
| let (tx, mut tr) = mpsc::channel(1); | ||
| let request = MockRequest { | ||
| app_id: "test_app_id".to_string(), | ||
| contract: RippleContract::Internal, | ||
| contract: RippleContract::RippleContext, | ||
| expected_response: None, | ||
| }; | ||
| let id = extn_client.subscribe(request.clone(), tx).await.unwrap(); | ||
|
|
||
| let msg = ExtnMessage { | ||
| id: id.clone(), | ||
| requestor: ExtnId::get_main_target("main".into()), | ||
| target: RippleContract::Internal, | ||
| target: RippleContract::RippleContext, | ||
| target_id: None, | ||
| payload: request.get_extn_payload(), | ||
| ts: Some(Utc::now().timestamp_millis()), | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should not be sending any
ExtnMessagehere. Instead use service message for propagating this error as JSON RPC error response.