Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
(1,259 changes in Cargo.lock)
This PR serves a few purposes:
** Plugin Provider **
Uses a static/const global RwLock (multiple simultaneous readers, ones writer), makes it more convenient to use plugin implementation without passing provider everywhere. Sometimes using global variables can create more problems then they solve, we need to be aware of that (I think in this case it should be fine).
I was trying to keep the impact of overwriting, quite happy with it.
This is a limited functionality prototype, I have a pretty big list of questions and improvements, that would be summarised in an issue and prioritised, so if you are looking at this PR I would suggest waiting for that list before going into a deep dive of thoughtful improvements/suggestions. (still in exploratory stage)
Next up is another example, of overwriting requested quantity in requisitions with API call (macro eye use case)
** How it works **
There is global plugin provider which stores dynamically dispatched trait implementations, those can be overwritten at runtime, 'plugin' endpoint allows you to upload one plugin for AMC calculation.
AMC calculation plugin implements a trait of filter/store_id input and output of HashMap of itemIds and AMC data, this plugin is called if it exists in plugin provider, or default implementation, when item stats are calculated.
Plugin is bound using extism wasm plugin framework, at the time of creating plugin instance, service provider reference is captured in a host function that is passed on to the plugin (a host function to do sql query)
** How to test/run **
cargo run
-> check AMC for items (catalogue -> item)See commands in
amc.js
(in the comment), should be able to build and upload plugin -> check AMC after upload of plugin