Open acarlson0000 opened 2 years ago
@acarlson0000 I am doing something similar: Fetching info from Open ID and JWKs endpoints.
This happens during startup and refreshen on a specified interval. I also wondered how this works and the solution is to dispatch calls in the on_tick
-Function. This function is called on every tick, which you can initially "turn on" with self.set_tick_period()
. I think you should run this setting of the period inside on_vm_start
.
Hope it helps and and this is not already resolved :)
I hope it's okay to extend this question somewhat as I have a related question. I've been creating similar functionality which loads some information from an API on tick to periodically update shared data. The problem I find with using on_tick is that is it triggered multiple times per duration of the tick, I guess due to multiple workers / threads which each has their own tick. Those are triggered at the same time, but I only want to call an API once in the tick duration so I don't spam the API with unnecessary requests. Anybody any idea how this can be achieved?
You could have separate singleton background service that fetches and updates data in key-value store, and workers could then read shared data from that key-value store.
Thanks for the idea! Let me research that option and I'll post here an example if I get something working
Hello - hope its okay to put a query through, but I'm looking for some pointers into how this may be possible. I'm an envoy/rust novice, so apologies if I have an incorrect grasp of this stuff!
For context; we're trying to write a WASM filter to perform CRL verification against an incoming Client Certificate subject.
Currently, I have the filter working whereby the first initial HTTP request that is incercepted by the filter fetches a list of CRLs, and adds it to shared data (ie working as a singleton). After which, further requests have use of it - however, I realise this isn't ideal.
Ideally, I'd like to fetch this file when the VM starts, and ensure it is added to shared buffer to make use of later, but I'm unsure exactly how to put this together. As I understand it, the
RootContext
trait won't get access to thedispatch_http_call
(or theon_http_call_response / get_http_call_response_body
, as these are part of theContext
trait. Nor am I able to use an additional request library (ie reqwest etc due to the obvious compilation issues).Provided a small example filter below.
Any help would be appreciated, thanks! I'm aware there are implications for how to refresh the cache / check expiry etc, but just wondering if this is even possible.