Skip to content
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

Define a IM/DM decoupling interface for interaction model engine to interact with the data model bits #32914

Merged
merged 61 commits into from
May 7, 2024
Merged
Changes from 1 commit
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
5697b48
Start adding a interaction model decoupling
andy31415 Apr 9, 2024
2a59741
Restyle
andy31415 Apr 9, 2024
d23acfa
Also add invoke responder bits
andy31415 Apr 9, 2024
67c6d29
Add the first model definition, for each operation
andy31415 Apr 9, 2024
a582d72
Add all files into the build definition
andy31415 Apr 9, 2024
efa1afe
Start adding the side effect support classes to the interaction model…
andy31415 Apr 9, 2024
4eeb04f
Add actions and integrate them to the IM model
andy31415 Apr 9, 2024
f4c3b46
Add iteration methods
andy31415 Apr 9, 2024
4abcb5e
Restyle
andy31415 Apr 9, 2024
34b646c
Add all files to the build definition
andy31415 Apr 9, 2024
02bc810
Start defining a unit test to at least validate compilation. Will lat…
andy31415 Apr 9, 2024
05a085a
Fix a dependency
andy31415 Apr 9, 2024
dfab9de
Move EventLoggingDelegate to be part of "events" in app.
andy31415 Apr 9, 2024
43308e8
Prepare for testing ... does not compile however TODOs are starting t…
andy31415 Apr 9, 2024
fa4cfa8
Fix SFINAE logic on eventing
andy31415 Apr 9, 2024
7fb1a3c
test that something is actually emitted for events
andy31415 Apr 9, 2024
e97254b
Tests actually do something
andy31415 Apr 9, 2024
f855e93
Some tests actually pass
andy31415 Apr 9, 2024
0aa318a
Restyle
andy31415 Apr 9, 2024
7e95ee7
Merge branch 'master' into im_dm_decoupling
andy31415 Apr 9, 2024
6e532a6
Minor style updates
andy31415 Apr 9, 2024
4c3391a
Merge branch 'master' into im_dm_decoupling
andy31415 Apr 11, 2024
0a0b315
Rename EmitEvent to GenerateEvent
andy31415 Apr 11, 2024
eb58bc9
Add description for paths
andy31415 Apr 11, 2024
d88fb0f
Cleanup some example text ... we do not need an exhaustive usage list
andy31415 Apr 11, 2024
acc842c
Restyle
andy31415 Apr 11, 2024
6886d0c
Fix spelling
andy31415 Apr 11, 2024
6c805d1
Renames based on code review: use UpperCamelCase
andy31415 Apr 11, 2024
bc5f9f6
Updated proposal for retries and paths
andy31415 Apr 11, 2024
b9db782
Restyle
andy31415 Apr 11, 2024
24176e9
one more comment
andy31415 Apr 11, 2024
cff6de1
Restyled by clang-format
restyled-commits Apr 11, 2024
7310b65
Fix typo in parameter type
andy31415 Apr 12, 2024
7d99ad5
Some updates for code review
andreilitvin Apr 16, 2024
c363ddd
Merge branch 'master' into im_dm_decoupling
andreilitvin Apr 16, 2024
c925cb4
Undo submodule update
andreilitvin Apr 16, 2024
72ea3cc
Fix logic error in buffer-too-small check for buffer data
andreilitvin Apr 16, 2024
1da1c87
Fix return error code when send encounters an error
andreilitvin Apr 16, 2024
036782f
Fix logic for mCompleted handling in the auto-complete handling
andreilitvin Apr 16, 2024
ddbe6a6
More comments
andreilitvin Apr 16, 2024
f3673ba
Comments
andreilitvin Apr 16, 2024
b220cf3
Use AAI types for interaction model. I think they will need some spli…
andreilitvin Apr 16, 2024
c2d2935
Update some naming to not use the a... syntax since those are odd
andreilitvin Apr 16, 2024
af649e2
Merge branch 'master' into im_dm_decoupling
andy31415 Apr 25, 2024
0c9cd9e
Code review updates
andy31415 Apr 25, 2024
7856b2e
Added extra comment
andy31415 Apr 25, 2024
e9c0039
Enforce lifetime in invoke responses
andy31415 Apr 25, 2024
e6cdc3e
More comments
andy31415 Apr 25, 2024
7a12efd
More comments
andy31415 Apr 25, 2024
8c86e3d
Restyle
andy31415 Apr 25, 2024
e4b0010
Added comment on replyasync with nullptr
andy31415 Apr 25, 2024
533d542
Update src/app/interaction-model/InvokeResponder.h
andy31415 Apr 25, 2024
4be818f
Update src/app/interaction-model/InvokeResponder.h
andy31415 Apr 25, 2024
492b6f9
Update src/app/interaction-model/InvokeResponder.h
andy31415 Apr 25, 2024
5f76b9c
Update src/app/interaction-model/InvokeResponder.h
andy31415 Apr 25, 2024
7e18454
Some code review updates
andreilitvin Apr 26, 2024
5844827
Some code review updates
andreilitvin Apr 26, 2024
e5e97a8
Merge branch 'im_dm_decoupling' of github.com:andy31415/connectedhome…
andreilitvin Apr 26, 2024
89c5bcf
Make the subject descriptor optional
andreilitvin Apr 26, 2024
ceea7b8
use std::optional instead of chip optiona
andreilitvin Apr 26, 2024
d134fab
Restyle
andreilitvin Apr 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Updated proposal for retries and paths
  • Loading branch information
andy31415 committed Apr 11, 2024
commit bc5f9f6b4f7087b150e9cc8a3d49b2821b4ec991
97 changes: 91 additions & 6 deletions src/app/interaction-model/InvokeResponder.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,48 @@ class InvokeResponder
InvokeResponder(const InvokeResponder &) = delete;
InvokeResponder & operator=(const InvokeResponder &) = delete;

virtual DataModel::WrappedStructEncoder & ReplyEncoder() = 0; // write the invoke reply
virtual CHIP_ERROR Complete(CHIP_ERROR error) = 0; // Complete the response (e.g. CHIP_NO_ERROR or CHIP_IM_GLOBAL_STATUS(...))
/// Flush any pending replies before encoding the current reply.
///
/// MAY be called at most once.
tehampson marked this conversation as resolved.
Show resolved Hide resolved
///
/// This function is intended to provided the ability to retry sending a reply
andy31415 marked this conversation as resolved.
Show resolved Hide resolved
/// if a reply encoding fails due to insufficient buffer.
///
/// Call this if `Complete(...)` returns CHIP_ERROR_BUFFER_TOO_SMALL and try
/// again. If reply data is needed, the complete ReplyEncoder + Complete
/// call chain MUST be re-run.
virtual CHIP_ERROR FlushPendingReplies() = 0;
andy31415 marked this conversation as resolved.
Show resolved Hide resolved

/// Reply with a data payload.
///
/// MUST be called at most once per reply.
/// Can be called a 2nd time after a `FlushPendingReplies()` call
///
/// - replyCommandId must correspond with the data encoded in the returned encoder
/// - Complete(CHIP_NO_ERROR) MUST be called to flush the reply
virtual DataModel::WrappedStructEncoder & ReplyEncoder(CommandId replyCommandId) = 0;
andy31415 marked this conversation as resolved.
Show resolved Hide resolved

/// Signal completing of the reply.
andy31415 marked this conversation as resolved.
Show resolved Hide resolved
///
/// MUST be called exactly once to signal a reply to be sent.
/// If this returns CHIP_ERROR_BUFFER_TOO_SMALL, this can be called a 2nd time after
/// a FlushPendingReplies.
///
/// Argument behavior:
/// - If an ERROR is given (i.e. NOT CHIP_NO_ERROR) an error response will be given to the
/// command.
/// - If CHIP_NO_ERROR is given:
/// - if a ReplyEncoder() was called, a data reply will be sent
/// - if no ReplyEncoder() was called, a Success reply will be sent
andy31415 marked this conversation as resolved.
Show resolved Hide resolved
///
/// Returns success/failure state. One error code MUST be handled in particular:
///
/// - CHIP_ERROR_BUFFER_TOO_SMALL will return IF AND ONLY IF the responder was unable
andy31415 marked this conversation as resolved.
Show resolved Hide resolved
/// to fully serialize the given reply/error data.
///
/// If such an error is returned, the caller MUST retry by calling
///
virtual CHIP_ERROR Complete(CHIP_ERROR error) = 0;
};

/// Enforces that once acquired, Complete will be called on the underlying writer
Expand All @@ -57,21 +97,66 @@ class AutoCompleteInvokeResponder
}
}

DataModel::WrappedStructEncoder & ReplyEncoder() { return mWriter->ReplyEncoder(); }
/// Direct access to reply encoding.
///
/// Use this only in conjunction with the other Raw* calls
DataModel::WrappedStructEncoder & RawReplyEncoder(CommandId replyCommandId) {
return mWriter->ReplyEncoder(replyCommandId);
}

/// Direct access to flushing replies
///
/// Use this only in conjunction with the other Raw* calls
CHIP_ERROR RawFlushPendingReplies() {
return mWriter->FlushPendingReplies();
}

/// Call "Complete" without the automatic retries.
///
/// Use this in conjunction with the other Raw* calls
CHIP_ERROR RawComplete(CHIP_ERROR error) {
return mWriter->Complete(error);
}

/// Complete the given command.
///
/// Automatically handles retries for sending.
CHIP_ERROR Complete(CHIP_ERROR error)
{
andy31415 marked this conversation as resolved.
Show resolved Hide resolved
mCompleted = true;
CHIP_ERROR err = mWriter->Complete(error);

if (err != CHIP_ERROR_BUFFER_TOO_SMALL) {
return err;
}

// retry once. Failure to flush is permanent.
ReturnErrorOnFailure(mWriter->FlushPendingReplies());
return mWriter->Complete(error);
tehampson marked this conversation as resolved.
Show resolved Hide resolved

return err;
}

/// Sends the specified data structure as a response
template <class ReplyData>
///
/// This version of the send has built-in RETRY and handles
/// Flush/Complete automatically.
///
template <typename ReplyData>
andy31415 marked this conversation as resolved.
Show resolved Hide resolved
CHIP_ERROR Send(const ReplyData & data)
{
andy31415 marked this conversation as resolved.
Show resolved Hide resolved
CHIP_ERROR err = data.Encode(ReplyEncoder());
CHIP_ERROR err = data.Encode(ReplyEncoder(ReplyData::GetCommandId()));
LogErrorOnFailure(err);
andy31415 marked this conversation as resolved.
Show resolved Hide resolved
err = mWriter->Complete(err);
if (err != CHIP_ERROR_BUFFER_TOO_SMALL) {
return err;
}

// retry once. Failure to flush is permanent.
ReturnErrorOnFailure(mWriter->FlushPendingReplies());
err = data.Encode(ReplyEncoder(ReplyData::GetCommandId()));
LogErrorOnFailure(err);
andy31415 marked this conversation as resolved.
Show resolved Hide resolved
return Complete(err);
return mWriter->Complete(err);
}

private:
Expand Down
Loading