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

[Task]: Implement sample Synapse API to Ballerina service mapping #43527

Open
HindujaB opened this issue Oct 28, 2024 · 2 comments
Open

[Task]: Implement sample Synapse API to Ballerina service mapping #43527

HindujaB opened this issue Oct 28, 2024 · 2 comments
Assignees
Labels
Team/jBallerina All the issues related to BIR, JVM backend code generation and runtime Type/Task

Comments

@HindujaB
Copy link
Contributor

Description

$subject

Describe your task(s)

No response

Related area

-> Runtime

Related issue(s) (optional)

No response

Suggested label(s) (optional)

No response

Suggested assignee(s) (optional)

No response

@HindujaB HindujaB self-assigned this Oct 28, 2024
@ballerina-bot ballerina-bot added the Team/jBallerina All the issues related to BIR, JVM backend code generation and runtime label Oct 28, 2024
@HindujaB
Copy link
Contributor Author

HindujaB commented Nov 4, 2024

Update:
A sample implementation was done to generate a Ballerina HTTP service from synapse API with the use of following.

  • synapse configuration builder APIs
  • Ballarina syntax APIs

Identified concerns:

  • There are some maintainability gaps in configuration builder APIs as they are no longer used by MI. Therefore some minor issues were found when parsing the synapse projects
  • MI currently uses separate APIs to create different synapse components. They are parsed in multiple calls. The tool needs to incorporate this.

@HindujaB
Copy link
Contributor Author

HindujaB commented Nov 8, 2024

[Update on 08/11/2024]

import ballerina/http;
import ballerina/log;

listener http:Listener HealthcareAPI = new (8290, config = {host: "localhost"});

service /healthcare on HealthcareAPI {
    resource function post categories/[string category]/reserve(http:Caller caller, http:Request req) returns error? {
        json payload = check req.getJsonPayload();
        string Hospital = check payload.hospital;
        http:Response res;
        match Hospital {
            "grand oak community hospital" => {
                log:printInfo("", message = "Routing to " + Hospital);
                http:Client GrandOakEP = check new (string `http://localhost:9090/grandoaks/categories/${category}/reserve`);
                res = check GrandOakEP->post("", req);
            }
            "pine valley community hospital" => {
                log:printInfo("", message = "Routing to " + Hospital);
                http:Client PineValleyEP = check new (string `http://localhost:9090/pinevalley/categories/${category}/reserve`);
                res = check PineValleyEP->post("", req);
            }
            "clemency medical center" => {
                log:printInfo("", message = "Routing to " + Hospital);
                http:Client ClemencyEP = check new (string `http://localhost:9090/clemency/categories/${category}/reserve`);
                res = check ClemencyEP->post("", req);
            }
            _ => {
                log:printInfo("", message = "Invalid hospital - " + Hospital);
                res = new;
                res.setPayload(payload);
            }
        }
        check caller->respond(res);
    }
}
  • Verified the mappability of the Property mediator & Log mediator
  • Analysed the expression configuration and equivalent Ballerina functionality
Expressions Reference Ballerina construct
Variables https://mi.docs.wso2.com/en/latest/reference/synapse-properties/expressions/#variables Ballerina variable retrieval
Functions https://mi.docs.wso2.com/en/latest/reference/synapse-properties/expressions/#functions Need specific library function calls
JSONPath expressions https://mi.docs.wso2.com/en/latest/reference/synapse-properties/expressions/#jsonpath-expressions json navigation expressions
XPath expressions https://mi.docs.wso2.com/en/latest/reference/synapse-properties/expressions/#xpath-expressions XML navigation expressions with query expressions

@HindujaB HindujaB moved this from In Progress to On Hold in Ballerina Team Main Board Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team/jBallerina All the issues related to BIR, JVM backend code generation and runtime Type/Task
Projects
Status: On Hold
Development

No branches or pull requests

2 participants