Skip to content

Comments

Add support for custom remote function mapping via Annotation#1553

Merged
MohamedSabthar merged 43 commits intoballerina-platform:mainfrom
chathushkaayash:feat/custom-remote-method-annotation
Apr 11, 2025
Merged

Add support for custom remote function mapping via Annotation#1553
MohamedSabthar merged 43 commits intoballerina-platform:mainfrom
chathushkaayash:feat/custom-remote-method-annotation

Conversation

@chathushkaayash
Copy link
Contributor

@chathushkaayash chathushkaayash commented Mar 26, 2025

Purpose

$subject

Resolves Support Custom Remote Function Mapping via Annotation

Examples

service class WsService {
    *websocket:Service;

    @websocket:DispatcherMapping {
        value: "subscribe"
    }
    remote function onSubscribeMessage(Subscribe message) returns string {
        return "Subscribed";
    }
}

Checklist

  • Linked to an issue
  • Updated the specification
  • Updated the changelog
  • Added tests
  • Checked native-image compatibility

@codecov
Copy link

codecov bot commented Mar 28, 2025

Codecov Report

Attention: Patch coverage is 97.72727% with 1 line in your changes missing coverage. Please review.

Project coverage is 82.42%. Comparing base (3a3f729) to head (7105638).
Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
...o/ballerina/stdlib/websocket/WebSocketService.java 95.23% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##               main    #1553   +/-   ##
=========================================
  Coverage     82.41%   82.42%           
- Complexity      599      601    +2     
=========================================
  Files            48       48           
  Lines          3111     3123   +12     
  Branches        414      414           
=========================================
+ Hits           2564     2574   +10     
- Misses          400      402    +2     
  Partials        147      147           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@chathushkaayash chathushkaayash marked this pull request as ready for review March 31, 2025 08:01
@ThisaruGuruge
Copy link
Member

Please check the Sonar analysis and whether we can fix the duplication warning.

@chathushkaayash chathushkaayash force-pushed the feat/custom-remote-method-annotation branch from 545f598 to 86b4168 Compare April 10, 2025 01:24
@chathushkaayash chathushkaayash force-pushed the feat/custom-remote-method-annotation branch from 86b4168 to 3a3f729 Compare April 10, 2025 01:42
@chathushkaayash chathushkaayash force-pushed the feat/custom-remote-method-annotation branch from e5c2e92 to 3a3f729 Compare April 10, 2025 14:03
@sonarqubecloud
Copy link

Comment on lines +174 to +177
if (funcDefinitionNode.qualifierList().stream()
.noneMatch(token -> token.text().equals(Qualifier.REMOTE.getValue()))) {
continue;
}
Copy link
Member

Choose a reason for hiding this comment

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

This is okay, but ideally, we should check this on function symbol. Can do something like this:

The reasons are follows;

There are two main APIs we use in compiler plugins;

  • Syntax API
  • Semantic API

Semantic API is more convenient and robust when it comes to validations IMO, because it exposes the semantic model instead of the raw syntax tree. When we use the Syntax API in compiler plugins to validate code, it takes more effort as we have to rely on string manipulations, string concatenations, etc., where semantic API provides more easy-to-use APIs for validation. (Of course there are instances where we have to use syntax APIs, and this is not to discourage the use of syntax API, but in the scenarios like these, it would be better to use Semantic API).

    FunctionSymbol functionSymbol = // Get the node from the semantic model
    if (!functionSymbol.qualifiers.contains(Qualifier.REMOTE) {
        continue;
    }

Copy link
Member

@ThisaruGuruge ThisaruGuruge left a comment

Choose a reason for hiding this comment

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

Added a minor comment, but LGTM

@MohamedSabthar MohamedSabthar merged commit 4b939e7 into ballerina-platform:main Apr 11, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support Custom Remote Function Mapping via Annotation in WebSocket Service

5 participants