Skip to content

Introduce Chrysalis protocol for async processing - #7

Closed
stevenproctor wants to merge 6 commits into
mainfrom
introduce_chrysalis_for_async_processing
Closed

stevenproctor wants to merge 6 commits into
mainfrom
introduce_chrysalis_for_async_processing

Conversation

@stevenproctor

Copy link
Copy Markdown
Contributor

Decouple dependence on core.async by introducing our own protocol to represent processing, while still allowing for core.async use if the client opts into using core.async by providing an optional namespace to include that allows a channel to implmement the Chrysalis protocol.

Also update examples to include the optional namespace so they can still work with core.async.

@stevenproctor

Copy link
Copy Markdown
Contributor Author

I opened this regarding @cch1's comment about splitting out the Protocol for decoupling from core.async from the async presentation form

#6 (review)

Comment thread test/lambda_toolshed/papillon_test.cljc Resolved
@stevenproctor

Copy link
Copy Markdown
Contributor Author

Still in progress as I am adding tests.

I am not sure Promises are working as desired.

They may not be flattening as I was hoping they would.

They also may not "present" correctly at the end since we catch and put the error in as the value, which kills the semantics of JavaScript Promises.

@stevenproctor

Copy link
Copy Markdown
Contributor Author

The idea that we discussed where we don't need the presenter as the client could define the "root" level interceptor in the chain to be responsible for transforming from one type of async result to another async type doesn't work.

It doesn't work because the outer wrapper is the first async type we come across, not the last.

@stevenproctor

Copy link
Copy Markdown
Contributor Author

Still need to add/verify tests for when:

  • a channel return follows a future return value, and
  • a future return follows a channel return value.

@stevenproctor

Copy link
Copy Markdown
Contributor Author

There looks to be some redundancy in the tests added around how futures and channels play together in the same interceptor chain. e.g., the presents-future-as-channel seems to be covered by the async versions of the future tests.

This is partly because I have it so futures can appear synchronous by blocking when we call emerge on an IDeref, and it matches the structure of it being synchronous and async using the go-test pattern the other sync tests use.

Not sure if it makes sense to keep the presents-as-channel to highlight where it might break if we change the emerge logic.

It may also make sense to have the test be more fine-grained around emerge on the different parts. Still, if done too "simplistically" by only calling the handler, we didn't correctly unwrap to the top-level but received the context deeply nested.

e.g., JS/Promise contained a Channel which contained a JS/Promise, etc.

Therefore the wrapped-handlers, that would be able to reach in and more deeply capture the result of the handler.

I also added tests for mixing and matching channels and promises to ensure we are not getting nested async types and only flattening out of the same async type.

Decouple dependence on core.async by introducing our own protocol
to represent processing, while still allowing for core.async use
if the client opts into using core.async by providing an optional
namespace to include that allows a channel to implmement the
Chrysalis protocol.

Also update examples to include the optional namespace so they
can still work with core.async.
- make promiser a `def`ed interceptor in cljs
- some intermittent test failures, so highlighting when
  the returning channel from alts! is not the expected
  interceptor channel
- add test for deeply mixing promises and channels
@stevenproctor
stevenproctor force-pushed the introduce_chrysalis_for_async_processing branch from b98bb38 to cad90b9 Compare July 22, 2023 16:28
@cch1 cch1 closed this Oct 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants