Skip to content

Commit

Permalink
Fix issues with incorrect plugins setup for WASM
Browse files Browse the repository at this point in the history
  • Loading branch information
dotansimha committed Nov 27, 2023
1 parent 9ce30c1 commit 923b25b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion libs/engine/src/gateway.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ impl ConductorGateway {

let combined_plugins = global_plugins
.iter()
.chain(&self.config.plugins)
.chain(&endpoint_config.plugins)
.flat_map(|vec| vec.iter())
.cloned()
.collect::<Vec<_>>();
Expand Down
7 changes: 7 additions & 0 deletions libs/engine/src/plugins/plugin_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use conductor_common::{
http::ConductorHttpResponse,
};
use conductor_config::PluginDefinition;
use tracing::debug;

use crate::request_execution_context::RequestExecutionContext;

Expand All @@ -22,6 +23,8 @@ impl PluginManager {
let mut instance = PluginManager::default();

if let Some(config_defs) = plugins_config {
debug!("config_defs: {:?}", config_defs);

config_defs.iter().for_each(|plugin_def| match plugin_def {
PluginDefinition::GraphiQLPlugin { config } => {
instance.register_plugin(GraphiQLPlugin(config.clone().unwrap_or_default()))
Expand All @@ -48,9 +51,13 @@ impl PluginManager {

#[tracing::instrument(level = "debug", skip(self, context))]
pub async fn on_downstream_http_request(&self, context: &mut RequestExecutionContext<'_>) {
debug!("on_downstream_http_request");
let p = &self.plugins;
debug!("plugins: {:?}", p.iter().count());

Check warning on line 56 in libs/engine/src/plugins/plugin_manager.rs

View workflow job for this annotation

GitHub Actions / clippy

called `.iter().count()` on a `slice`

warning: called `.iter().count()` on a `slice` --> libs/engine/src/plugins/plugin_manager.rs:56:33 | 56 | debug!("plugins: {:?}", p.iter().count()); | ^^^^^^^^^^^^^^^^ help: try: `p.len()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#iter_count = note: `#[warn(clippy::iter_count)]` on by default

for plugin in p.iter() {
debug!("calling plugin: {:?}", plugin);

plugin.on_downstream_http_request(context).await;

if context.is_short_circuit() {
Expand Down
6 changes: 1 addition & 5 deletions test_config/worker.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
server:
port: 9000

logger:
level: debug
format: pretty

sources:
- id: countries
Expand All @@ -15,5 +11,5 @@ endpoints:
- path: /graphql
from: countries
plugins:
- type: graphiql
- type: http_get
- type: graphiql

0 comments on commit 923b25b

Please sign in to comment.