Open HindujaB opened 2 weeks ago
Update: A sample implementation was done to generate a Ballerina HTTP service from synapse API with the use of following.
Identified concerns:
[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 |
- Identified several gaps
- Type conversion in ballerina needs to be handled ( if there is no `type` parameter is present)
- Synapse `scope` concept is not directly mappable ( https://mi.docs.wso2.com/en/latest/reference/synapse-properties/scopes/)
- Error handling needs to be handled separately (Fault sequence, other runtime exceptions)
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