Skip to content
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

Plugins AMC example #4806

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft

Plugins AMC example #4806

wants to merge 1 commit into from

Conversation

andreievg
Copy link
Collaborator

@andreievg andreievg commented Sep 17, 2024

(1,259 changes in Cargo.lock)

This PR serves a few purposes:

  • Keep team updated on plugin prototype work
  • Creates some context for technical discussions
  • Historic reference for progression of plugin technical design

** 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

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.

1 participant