-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Dispatch 'complete' event when streaming connection closed #383
Conversation
Codecov Report
@@ Coverage Diff @@
## dev #383 +/- ##
==========================================
+ Coverage 96.73% 96.77% +0.04%
==========================================
Files 27 27
Lines 1653 1671 +18
==========================================
+ Hits 1599 1617 +18
Misses 54 54 |
Add more functional test cases for onComplete behavior
Correct the documentation for response content as a fallback to error response content Alphabetize items
Reorganize view to move scrollable data view to the top and not truncate text Add visual indicators to scrollable data view
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.
Looks good. Added comments for a few minor issues.
@@ -64,10 +64,10 @@ class NetworkResponseHandler { | |||
/// Remove the requestId in the internal `sentEventsWaitingResponse` along with the associated list of events. | |||
/// - Parameter requestId: batch request id | |||
/// - Returns: the list of unique event ids associated with the requestId that were removed |
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.
Update comment to state it returns the events.
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.
Updated!
XCTAssertEqual(1, dispatchedEvents.count) | ||
|
||
let flattenedData = flattenDictionary(dict: dispatchedEvents.first?.data ?? [:]) | ||
XCTAssertEqual(1, flattenedData.count) | ||
XCTAssertEqual(requestID, flattenedData["requestId"] as? String) |
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.
You can use assertResponseCompleteEventWithData
here.
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.
Thank you! Updated
Documentation/event-reference.md
Outdated
|
||
### Edge response content | ||
|
||
This event is a response to an [Edge request content](#edge-request-content) event. | ||
This event is a fallback to an [Edge error response content](#edge-error-response-content) event. |
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.
This is technically the fallback when a network response handle doesn't define a type, not for errors. I've updated the Android definition to state this event include the Edge Network response handles and com.adobe.eventSource.responseContent is used if the response handle doesn't define a type. I'm not sure if we want to include that specific of information, however.
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.
Thank you for clarifying! I've updated to align with the updates you've made on the Android side. I think it could be helpful to include in the off chance someone runs into this event case and uses the reference
Documentation/event-reference.md
Outdated
The `sendCompletion` flag is used within the Edge request to indicate whether a "complete" event should be dispatched once the streaming connection is closed. This flag is part of the `request` object, which is at the same hierarchical level as the `data` and `xdm` objects in the Edge Experience Event. | ||
|
||
```json | ||
{ | ||
"xdm": { ... }, | ||
"request": { "sendCompletion" : true } | ||
} | ||
``` | ||
|
||
When the `sendCompletion` flag in the request is set to `true`, the Edge extension will dispatch a *paired* response event. This event notifies the caller that the connection has been closed and that no further streaming response handles will be dispatched. The [response event](#edge-content-complete) includes only the `requestId` in its data, for debugging purposes. The `parentID` of this event corresponds to the UUID of the originating request event. |
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.
I like this write up, however these parameters are only send in the request content events. Having a separate flags section seems to imply that any of the request event could contain the sendCompletion
flag. In the Android PR, I've split this information to include the request
parameter in the request content section, while adding the sendCompletion
in the content complete section. Having all this under the request content section is a good option too. What do you think?
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.
I agree that having the flags section separate could be confusing; I like the way that you've organized the information! Updated to align this doc with the latest Android changes
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.
Thanks for the review @kevinlind! Updated based on feedback
@@ -64,10 +64,10 @@ class NetworkResponseHandler { | |||
/// Remove the requestId in the internal `sentEventsWaitingResponse` along with the associated list of events. | |||
/// - Parameter requestId: batch request id | |||
/// - Returns: the list of unique event ids associated with the requestId that were removed |
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.
Updated!
XCTAssertEqual(1, dispatchedEvents.count) | ||
|
||
let flattenedData = flattenDictionary(dict: dispatchedEvents.first?.data ?? [:]) | ||
XCTAssertEqual(1, flattenedData.count) | ||
XCTAssertEqual(requestID, flattenedData["requestId"] as? String) |
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.
Thank you! Updated
Documentation/event-reference.md
Outdated
|
||
### Edge response content | ||
|
||
This event is a response to an [Edge request content](#edge-request-content) event. | ||
This event is a fallback to an [Edge error response content](#edge-error-response-content) event. |
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.
Thank you for clarifying! I've updated to align with the updates you've made on the Android side. I think it could be helpful to include in the off chance someone runs into this event case and uses the reference
Documentation/event-reference.md
Outdated
The `sendCompletion` flag is used within the Edge request to indicate whether a "complete" event should be dispatched once the streaming connection is closed. This flag is part of the `request` object, which is at the same hierarchical level as the `data` and `xdm` objects in the Edge Experience Event. | ||
|
||
```json | ||
{ | ||
"xdm": { ... }, | ||
"request": { "sendCompletion" : true } | ||
} | ||
``` | ||
|
||
When the `sendCompletion` flag in the request is set to `true`, the Edge extension will dispatch a *paired* response event. This event notifies the caller that the connection has been closed and that no further streaming response handles will be dispatched. The [response event](#edge-content-complete) includes only the `requestId` in its data, for debugging purposes. The `parentID` of this event corresponds to the UUID of the originating request event. |
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.
I agree that having the flags section separate could be confusing; I like the way that you've organized the information! Updated to align this doc with the latest Android changes
Description
Paired with Android implementation adobe/aepsdk-edge-android#83
This PR updates:
NetworkResponseHandler
to add a new method processResponseOnComplete which handles the sending of "complete" eventssendCompletion
flag set totrue
Related Issue
Motivation and Context
How Has This Been Tested?
Screenshots (if appropriate):
Types of changes
Checklist: