Skip to content

Commit ca059f8

Browse files
authored
Revision: Explain why ~Copyable was removed
1 parent e75c0d4 commit ca059f8

File tree

1 file changed

+13
-0
lines changed
  • Sources/AWSLambdaRuntimeCore/Documentation.docc/Proposals

1 file changed

+13
-0
lines changed

Sources/AWSLambdaRuntimeCore/Documentation.docc/Proposals/0001-v2-api.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -884,6 +884,19 @@ handler protocols:
884884
(with a single call to `writeAndFinish(_:)`). After closing the `LambdaResponseStreamWriter`, any background work can
885885
be implemented.
886886

887+
### Making LambdaResponseStreamWriter and LambdaResponseWriter ~Copyable
888+
889+
We initially proposed to make the `LambdaResponseStreamWriter` and `LambdaResponseWriter` protocols `~Copyable`, with
890+
the functions that close the response having the `consuming` ownership keyword. This was so that the compiler could
891+
enforce the restriction of not being able to interact with the writer after the response stream has closed.
892+
893+
However, non-copyable types do not compose nicely and add complexity for users. Further, for the compiler to actually
894+
enforce the `consuming` restrictions, user's have to explicitly mark the writer argument as `consuming` in the `handle`
895+
function.
896+
897+
Therefore, throwing appropriate errors to prevent abnormal interaction with the writers seems to be the simplest
898+
approach.
899+
887900
## A word about versioning
888901

889902
We are aware that AWS Lambda Runtime has not reached a proper 1.0. We intend to keep the current implementation around

0 commit comments

Comments
 (0)