geyser: add `is_reload` argument to `on_load` (#33674)
geyser: add `is_reload` argument to `on_load`
This commit is contained in:
parent
c55a6e55a1
commit
5a0828330d
|
@ -329,7 +329,7 @@ pub trait GeyserPlugin: Any + Send + Sync + std::fmt::Debug {
|
||||||
/// of the config file. The config must be in JSON format and
|
/// of the config file. The config must be in JSON format and
|
||||||
/// include a field "libpath" indicating the full path
|
/// include a field "libpath" indicating the full path
|
||||||
/// name of the shared library implementing this interface.
|
/// name of the shared library implementing this interface.
|
||||||
fn on_load(&mut self, _config_file: &str) -> Result<()> {
|
fn on_load(&mut self, _config_file: &str, _is_reload: bool) -> Result<()> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -109,7 +109,7 @@ impl GeyserPluginManager {
|
||||||
|
|
||||||
// Call on_load and push plugin
|
// Call on_load and push plugin
|
||||||
new_plugin
|
new_plugin
|
||||||
.on_load(new_config_file)
|
.on_load(new_config_file, false)
|
||||||
.map_err(|on_load_err| jsonrpc_core::Error {
|
.map_err(|on_load_err| jsonrpc_core::Error {
|
||||||
code: ErrorCode::InvalidRequest,
|
code: ErrorCode::InvalidRequest,
|
||||||
message: format!(
|
message: format!(
|
||||||
|
@ -194,7 +194,7 @@ impl GeyserPluginManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Attempt to on_load with new plugin
|
// Attempt to on_load with new plugin
|
||||||
match new_plugin.on_load(new_parsed_config_file) {
|
match new_plugin.on_load(new_parsed_config_file, true) {
|
||||||
// On success, push plugin and library
|
// On success, push plugin and library
|
||||||
Ok(()) => {
|
Ok(()) => {
|
||||||
self.plugins.push(new_plugin);
|
self.plugins.push(new_plugin);
|
||||||
|
@ -430,7 +430,7 @@ mod tests {
|
||||||
|
|
||||||
// Mock having loaded plugin (TestPlugin)
|
// Mock having loaded plugin (TestPlugin)
|
||||||
let (mut plugin, lib, config) = dummy_plugin_and_library(TestPlugin, DUMMY_CONFIG);
|
let (mut plugin, lib, config) = dummy_plugin_and_library(TestPlugin, DUMMY_CONFIG);
|
||||||
plugin.on_load(config).unwrap();
|
plugin.on_load(config, false).unwrap();
|
||||||
plugin_manager_lock.plugins.push(plugin);
|
plugin_manager_lock.plugins.push(plugin);
|
||||||
plugin_manager_lock.libs.push(lib);
|
plugin_manager_lock.libs.push(lib);
|
||||||
// plugin_manager_lock.libs.push(lib);
|
// plugin_manager_lock.libs.push(lib);
|
||||||
|
@ -465,12 +465,12 @@ mod tests {
|
||||||
// Load two plugins
|
// Load two plugins
|
||||||
// First
|
// First
|
||||||
let (mut plugin, lib, config) = dummy_plugin_and_library(TestPlugin, TESTPLUGIN_CONFIG);
|
let (mut plugin, lib, config) = dummy_plugin_and_library(TestPlugin, TESTPLUGIN_CONFIG);
|
||||||
plugin.on_load(config).unwrap();
|
plugin.on_load(config, false).unwrap();
|
||||||
plugin_manager_lock.plugins.push(plugin);
|
plugin_manager_lock.plugins.push(plugin);
|
||||||
plugin_manager_lock.libs.push(lib);
|
plugin_manager_lock.libs.push(lib);
|
||||||
// Second
|
// Second
|
||||||
let (mut plugin, lib, config) = dummy_plugin_and_library(TestPlugin2, TESTPLUGIN2_CONFIG);
|
let (mut plugin, lib, config) = dummy_plugin_and_library(TestPlugin2, TESTPLUGIN2_CONFIG);
|
||||||
plugin.on_load(config).unwrap();
|
plugin.on_load(config, false).unwrap();
|
||||||
plugin_manager_lock.plugins.push(plugin);
|
plugin_manager_lock.plugins.push(plugin);
|
||||||
plugin_manager_lock.libs.push(lib);
|
plugin_manager_lock.libs.push(lib);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue