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

5829 load plugins via processor #6399

Open
wants to merge 6 commits into
base: 6396-CLI-to-generate-and-isntall-plugin-bundle
Choose a base branch
from

Conversation

andreievg
Copy link
Collaborator

Fixes #5829

πŸ‘©πŸ»β€πŸ’» What does this PR do?

Adds a new processor to load plugins to plugin provider (so that after sync plugins are loaded without restart).
Plugins are also loaded at startup.
Added enum test, key_type_enum, to make sure key types in key value store match database type definitions

πŸ’Œ Any notes for the reviewer?

πŸ§ͺ Testing

Setup remote site and central site on this version. Sync them. Then run

cargo run --bin remote_server_cli -- generate-and-install-plugin-bundle -i './service/src/backend_plugin/examples/amc' -u 'http://localhost:8000' --username 'test' --password 'pass'

Above will upload plugin to central sever, after syncing remote site you should see AMC calculated per amc.js file. On servers restart you should still see AMC calculater as per amc.js file

@github-actions github-actions bot added this to the v2.6.0 milestone Feb 3, 2025
@github-actions github-actions bot added enhancement New feature or request Team Ruru πŸ¦‰ Roxy, Ferg, Noel feature: plugin labels Feb 3, 2025
@@ -16,8 +16,9 @@ table! {
}
}

// Database: https://github.com/openmsupply/open-msupply/blob/d6645711184c63593949c3e8b6dc96b5a5ded39f/server/repository/migrations/postgres/2022-02-11T15-00_create_key_value_store/up.sql#L2-L16
// Snippet for adding new, including migration : https://github.com/msupply-foundation/open-msupply/wiki/Snippets "New Key Type for KeyValueStore"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a snippet for this, for future additions

#[derive(DbEnum, Debug, Clone, PartialEq, Eq, Default)]
#[cfg_attr(test, derive(strum::EnumIter))]
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test wasn't stricly necessary, but was quick to add and doesn't add too much extra code, sorry to the reviewer

@@ -147,11 +147,14 @@ pub async fn start_server(
}

// PLUGIN CONTEXT

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, sorry for format change

}

ctx.processors_trigger
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A trigger would work here, since rows have been upserted


#[derive(Error, Debug)]
pub(crate) enum ProcessorError {
#[error("{0:?} not found: {1:?}")]
#[error("{0} not found: {1}")]
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Chnaged error mapping, tehnically should just do [source] or from for existing error and they will be added to the error message without needing to print them out

changelog.record_id.clone(),
))?;

PluginInstance::bind(plugin);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty simple processor to just just call 'bind'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request feature: plugin Team Ruru πŸ¦‰ Roxy, Ferg, Noel
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant