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

Setup services from configuration #78

Merged
merged 3 commits into from
Aug 29, 2024

Conversation

adam-cattermole
Copy link
Member

Changes

Builds on top of the GrpcServiceHandler added previously to configure these at the plugin configuration stage:

Most of the fields in the GrpcServiceHandler had a lifetime that was for the duration of the wasm filter (the stuff read from configuration), but the lifetime of the header resolver is only for each http request. I've moved these fields out to a new GrpcService.

GrpcService

  • The method and name currently come from a static variable, so I'm using &'static str for these instead of String as I didn't want to create copies of these just to convert them back to references in send
  • The GrpcService currently also contains the failure_mode now instead of storing this config-wide

Update Configuration

  • A new extensions field has been added to the PluginConfiguration that is defined as follows:
"extensions": {
    "limitador": {
        "type": "ratelimit",
        "endpoint": "limitador-cluster",
        "failureMode": "deny"
    }
},
  • I have updated the configuration to build the set of GrpcServices from the extensions deserialised in the initial step of the TryFrom - for now I'm storing them as an Rc<HashMap<String,Rc<GrpcService>>> - the String being the key of the extension that can be used to reference which service from the actions.
    • Perhaps we can iterate on this storage structure - I chose to use an Rc for the HashMap so that it can be re-used across all http requests as these are configured from the plugin config. However I also chose to have the GrpcServices as an Rc so that the ref can be cloned to each of the GrpcServiceHandler
  • Currently this is used by taking the first GrpcService and using that as the service. Once we have an idea of how the actions will be defined we could retrieve the correct service for the action

@@ -504,8 +523,16 @@ pub enum ExtensionType {
#[derive(Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
pub struct PluginConfiguration {
#[serde(rename = "rateLimitPolicies")]
Copy link
Member Author

Choose a reason for hiding this comment

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

I've removed this rename, so it's no longer rateLimitPolicies and now just policies

Signed-off-by: Adam Cattermole <[email protected]>
Copy link
Member

@didierofrivia didierofrivia left a comment

Choose a reason for hiding this comment

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

🍬

@adam-cattermole adam-cattermole merged commit ed8eec1 into external-auth Aug 29, 2024
8 checks passed
@adam-cattermole adam-cattermole deleted the service-from-config branch August 29, 2024 13:37
@didierofrivia didierofrivia mentioned this pull request Oct 1, 2024
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants