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

feat: support for external middleware plugins #83

Merged

Conversation

michaeladler
Copy link
Member

Description

This commit introduces possibility to integrate external middleware plugins. These plugins have the possibility to modify incoming HTTP requests prior to routing. This includes modifying headers, routing and denying requests.

Due to the lack of a proper plugin system in Go, external middleware plugins are implemented as standalone sub-processes. They communicate with wfx via protobuf message over stdin/stdout, hence it's crucial for the plugin to read from stdin promptly to avoid blocking wfx. An example plugin written in Go is included in the example/plugin subdirectory, taking special care that stdin does not block.

Issues Addressed

List and link all the issues addressed by this PR.

Change Type

Please select the relevant options:

  • Bug fix (non-breaking change that resolves an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist

  • I have read the CONTRIBUTING document.
  • My changes adhere to the established code style, patterns, and best practices.
  • I have added tests that demonstrate the effectiveness of my changes.
  • I have updated the documentation accordingly (if applicable).
  • I have added an entry in the CHANGELOG to document my changes (if applicable).

@michaeladler michaeladler requested a review from stormc as a code owner November 20, 2023 16:20
Copy link

codecov bot commented Nov 20, 2023

Codecov Report

Attention: 62 lines in your changes are missing coverage. Please review.

Comparison is base (e38ac68) 79.85% compared to head (14037c9) 80.27%.

Files Patch % Lines
middleware/plugin/fbplugin.go 72.34% 19 Missing and 7 partials ⚠️
middleware/plugin/middleware.go 86.77% 11 Missing and 5 partials ⚠️
cmd/wfx/cmd/root/plugins.go 88.13% 4 Missing and 3 partials ⚠️
middleware/plugin/process_unix.go 81.25% 4 Missing and 2 partials ⚠️
middleware/plugin/ioutil/io.go 93.02% 2 Missing and 1 partial ⚠️
cmd/wfx/cmd/root/cmd.go 77.77% 2 Missing ⚠️
cmd/wfx/cmd/root/northbound.go 95.00% 1 Missing ⚠️
cmd/wfx/cmd/root/southbound.go 94.73% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #83      +/-   ##
==========================================
+ Coverage   79.85%   80.27%   +0.41%     
==========================================
  Files          85       89       +4     
  Lines        3376     3747     +371     
==========================================
+ Hits         2696     3008     +312     
- Misses        492      533      +41     
- Partials      188      206      +18     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@michaeladler michaeladler force-pushed the 43-plugin-system-for-external-middlewares branch 4 times, most recently from 521b212 to 35a8e04 Compare November 21, 2023 12:29
@michaeladler michaeladler marked this pull request as draft November 21, 2023 13:42
@michaeladler michaeladler force-pushed the 43-plugin-system-for-external-middlewares branch 11 times, most recently from 381dc8a to 58fe750 Compare November 23, 2023 10:18
@michaeladler michaeladler marked this pull request as ready for review November 23, 2023 10:22
@michaeladler michaeladler force-pushed the 43-plugin-system-for-external-middlewares branch from 58fe750 to 990b111 Compare December 1, 2023 09:43
cmd/wfx/cmd/root/flags.go Outdated Show resolved Hide resolved
@michaeladler michaeladler force-pushed the 43-plugin-system-for-external-middlewares branch from 990b111 to 7836279 Compare December 13, 2023 15:49
example/plugin/main.go Outdated Show resolved Hide resolved
@michaeladler michaeladler force-pushed the 43-plugin-system-for-external-middlewares branch 4 times, most recently from b032a83 to b642140 Compare December 15, 2023 12:29
docs/operations.md Outdated Show resolved Hide resolved
docs/operations.md Outdated Show resolved Hide resolved
example/plugin/main.go Outdated Show resolved Hide resolved
example/plugin/main.go Outdated Show resolved Hide resolved
docs/operations.md Outdated Show resolved Hide resolved
fbs/client/response.fbs Outdated Show resolved Hide resolved
docs/operations.md Outdated Show resolved Hide resolved
middleware/plugin/plugin.go Outdated Show resolved Hide resolved
@michaeladler michaeladler force-pushed the 43-plugin-system-for-external-middlewares branch 11 times, most recently from 45f8d96 to b77e30b Compare December 20, 2023 16:37
docs/operations.md Outdated Show resolved Hide resolved
docs/operations.md Outdated Show resolved Hide resolved
cmd/wfx/cmd/root/plugins.go Show resolved Hide resolved
cmd/wfx/cmd/root/southbound.go Show resolved Hide resolved
example/plugin/main.go Outdated Show resolved Hide resolved
middleware/plugin/disabled.go Outdated Show resolved Hide resolved
middleware/plugin/fbplugin.go Outdated Show resolved Hide resolved
middleware/plugin/middleware.go Show resolved Hide resolved
middleware/plugin/middleware.go Show resolved Hide resolved
middleware/plugin/middleware.go Outdated Show resolved Hide resolved
@michaeladler michaeladler force-pushed the 43-plugin-system-for-external-middlewares branch 2 times, most recently from ba78a2c to 8ddcc77 Compare January 3, 2024 14:39
This commit introduces possibility to integrate external middleware
plugins. These plugins have the possibility to modify incoming HTTP
requests prior to routing. This includes modifying headers, routing and
denying requests.

Due to the lack of a proper plugin system in Go, external middleware
plugins are implemented as standalone sub-processes. They communicate
with wfx via protobuf message over stdin/stdout, hence it's crucial for
the plugin to read from stdin promptly to avoid blocking wfx. An example
plugin written in Go is included in the `example/plugin` subdirectory,
taking special care that stdin does not block.

Signed-off-by: Michael Adler <[email protected]>
@michaeladler michaeladler force-pushed the 43-plugin-system-for-external-middlewares branch from 7fbd177 to 14037c9 Compare January 10, 2024 08:01
@stormc stormc merged commit 9140600 into siemens:main Jan 10, 2024
13 checks passed
@michaeladler michaeladler deleted the 43-plugin-system-for-external-middlewares branch January 10, 2024 08:42
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.

2 participants