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

Introduce dynamic parameter order for the websubhub:Service remote methods #7600

Closed
ayeshLK opened this issue Feb 17, 2025 · 1 comment · Fixed by ballerina-platform/module-ballerina-websubhub#1082
Assignees
Labels
module/websubhub Issues related to Ballerina websubhub module Type/Improvement

Comments

@ayeshLK
Copy link
Member

ayeshLK commented Feb 17, 2025

Current Limitation

In the current implementation, the parameter order for websubhub:Service methods is static. Consider the following example:

service /websubhub on securedListener {

    remote function onRegisterTopic(websubhub:TopicRegistration message, http:Headers headers)
                                returns websubhub:TopicRegistrationSuccess|websubhub:TopicRegistrationError {
        
        // logic to be executed
    }

    // other methods
}

Here, the http:Headers parameter is optional, meaning users can choose to omit it. However, if we introduce another optional parameter, such as websubhub:Controller, the method signature would need to be modified as follows:

service /websubhub on securedListener {

    remote function onRegisterTopic(websubhub:TopicRegistration message, http:Headers headers, websubhub:Controller hubController)
                                returns websubhub:TopicRegistrationSuccess|websubhub:TopicRegistrationError {
        
        // logic to be executed
    }

    // other methods
}

With this approach, users must define the http:Headers parameter even if they do not use it, since the method parameters follow a fixed order.

To enhance flexibility, parameter ordering should not be strictly enforced. Instead, a more dynamic approach should be introduced to determine parameter order at runtime, allowing optional parameters to be omitted without affecting method invocation.

Suggested Improvement

Introduce dynamic parameter order which provides the flexibility to omit optional parameters as needed and define parameters in any order.

Version

Ballerina SL 2201.11.0 / Ballerina Websubhub v1.13.0

@ayeshLK ayeshLK added module/websubhub Issues related to Ballerina websubhub module Type/Improvement labels Feb 17, 2025
@ayeshLK ayeshLK self-assigned this Feb 17, 2025
@ayeshLK
Copy link
Member Author

ayeshLK commented Feb 17, 2025

This feature is an required improvement to implement the Subscription autoverification feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module/websubhub Issues related to Ballerina websubhub module Type/Improvement
Projects
Status: Done
1 participant