Policy Development Kit Architecture Overview
Flex Gateway Policy Development Kit (PDK) consists of:
-
Anypoint CLI PDK Plugin: Generates and distributes the policy to Exchange
-
Policy Template: Scaffolds new custom policies
-
SDK Building Tools: Simplifies the development process
Anypoint CLI PDK Plugin
The Anypoint CLI PDK plugin creates the PDK project and uploads policy assets to Exchange (for Connected Mode only). After creating the project, PDK provides a simplified set of commands in a Makefile
to complete all following development steps.
Policy Template
PDK generates some simple scaffolding when creating the policy.
All generated files contain the required information to properly compile the policy.
For more information about the included files, see Project Structure.
SDK Building Tools
Flex Gateway is built on Envoy which requires developed policies to be compatible with the event-driven proxy-wasm architecture.
`proxy-wasm’s event-driven architecture requires users to manage the different events that handle a single request. This causes the following drawbacks that make developing and maintaining event-driven code costly:
-
High complexity of the code due to the coupling of business logic with the entry points
-
Inability to modularize common logic which creates monolithic code
-
Verbose non-linear control flow that creates difficult function callbacks and error propagation
PDK provides building tools that abstract the developer from the event-oriented coding approach by using reactor and executor patterns. PDK provides the developer a way to code each incoming request in a linear method that results in:
-
Fewer compile and runtime errors from using methods in the incorrect context
-
Reduced learning curve
-
Improved debugging by minimizing call stacks
-
Reduced code duplication
-
Improved parameter injection
-
Reduced use of dynamic memory that decreases indeterminism and the need for custom memory management