feat(request-aware-table) add request aware table
Summary
Add a request-aware table able to detect accesses from different requests.
Checklist
- [x] The Pull Request has tests
- [x] (na) There's an entry in the CHANGELOG
- [x] (na) There is a user-facing docs PR against https://github.com/Kong/docs.konghq.com - PUT DOCS PR HERE
Full changelog
- [Implement ...]
Issue reference
What is request aware table in comparison to ngx.ctx or kong.ctx.plugin|shared?
What is request aware table in comparison to
ngx.ctxorkong.ctx.plugin|shared?
I wondered that myself @bungle, thanks for bringing it up.
The main difference is that this table can detect race conditions and throw an error if they happen, instead of using separate scopes for each request to prevent them.
Race condition checks (which currently require an access to ngx.var per request) would only be turned on during testing, to ensure the table is used properly (i.e. cleared before it's accessed by another request). This allows defining a table that is local to the module where it is instantiated, can be cleared at will, and does not rely on a shared context.
However, if the performance impact of accessing this table compared to using the context is not significant, we could solve the same problem just as in this PR, using kong.ctx.plugin to prevent race conditions in the first place.
I'd be curious to hear @dndx 's opinion as well
@dndx could you take a look at this PR again? thx