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
provide rhai surrogate cache key example #1136
Conversation
What is causing the de-serialization error?
To pull in Geoffroy's rhai contribution for serde. Clean up the example and think about the best way to expose upsert to rhai.
Fix the implementation of upsert() and update the example to use the new upsert().
Until the next release of rhai. Needed to pull in the fix for map serialization.
✅ Deploy Preview for apollo-router-docs ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
This comment has been minimized.
This comment has been minimized.
- Added feature line to changelog - (clean up dead commented out line in Cargo.toml) - Document new Context::upsert() support in rhai - Document new surrogate cache key example
code review comment
let map_callback = |response| { | ||
try { | ||
// IMPORTANT: Take a copy of the cache-key here | ||
// to avoid deadlock in the closure. |
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.
maybe the documentation should have a section about that deadlock risk
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.
That's a general rhai
risk rather than anything specific about how we use it. I will think about the best way to incorporate something that references this.
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've added a section to the docs: 3f08c90
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.
@Geal Could you take a look at the changes I added?
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.
sure
Try to call out some of the dangers of deadlock with shared values.
This provides an example of reading subgraph header responses and creating a composite surrogate key.
The approach taken is to override:
This approach makes use of the new Context::upsert() function which is added to the rhai implementation.
Note: The rhai dependency is bound to a specific git rev since we require a serialization fix in rhai (provided by @Geal ) and which hasn't been released yet.
fixes: #648