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

Proper service type descriptor #329

Closed
riyafa opened this issue Sep 4, 2019 · 2 comments
Closed

Proper service type descriptor #329

riyafa opened this issue Sep 4, 2019 · 2 comments
Labels
Area/Lang Relates to the Ballerina language specification Type/Improvement Enhancement to language design

Comments

@riyafa
Copy link

riyafa commented Sep 4, 2019

Description:
Currently all the services are of the generic type service and hence the __attach life cycle function of all the listeners take the same service. This has caused complications in differentiating services when the same listener supports two different service types (Eg. http:Listener supports both WebSocket and http services.) In this case it is difficult to have proper compiler validations. Although we have certain hacks in the compiler plugin that uses the resource parameters to validate the service, these are not proper solutions as we get odd compiler messages at certain times.
Also compile time validations are complicated when defining the service as a separate variable. In this case also resource parameters are used for compiler validation which is not particularly useful in all instances. One example is here.
This also causes issues in tooling code generation because, the tooling also need to depend on the listener or other means to generate code snippets.
Related mail thread though a little outdated: https://groups.google.com/d/msg/ballerina-dev/AicMMCXL8kA/w9l1vNz1CAAJ

Code sample that shows issue:
Attaching two services to same listener:

service serviceName on new http:Listener(9090) {
    resource function onOpen(http:WebSocketCaller caller) {
        
    }
}
service serviceName on new http:Listener(9090) {
     resource function newResource(http:Caller caller, http:Request request) {
        
    }
}

Defining service as a different variable:
https://gist.github.com/riyafa/3f0b31ce53a75911d7ef1bc00ff43b83

Related Issues:
ballerina-platform/ballerina-lang#14148

@riyafa riyafa added design/usability Design does not work well for some tasks Area/Platform Relates to the Ballerina platform spec/improve Something that should be improved in the spec status/discuss Needs discussion outside github comments labels Sep 4, 2019
@jclark jclark added Type/Improvement Enhancement to language design Area/Lang Relates to the Ballerina language specification and removed design/usability Design does not work well for some tasks Area/Platform Relates to the Ballerina platform status/discuss Needs discussion outside github comments spec/improve Something that should be improved in the spec labels Sep 4, 2019
@jclark jclark modified the milestones: 2019R4, 2020R1 Sep 4, 2019
@jclark
Copy link
Collaborator

jclark commented Sep 4, 2019

This is definitely on our radar.

Until gets this added to the language, the idea is that you can annotate the service type.

@service { type: "http" }
type HttpService service;

You then treat the abstract type Listener as being parameterized in the service type i.e. as Listener<S> where S is the annotated service type.

Relates to #278 and #290.

@jclark jclark changed the title Support service typing Provide more precise typing of services Nov 20, 2019
@jclark jclark changed the title Provide more precise typing of services Proper service type descriptor Jun 30, 2020
@jclark
Copy link
Collaborator

jclark commented Sep 26, 2020

This will be dealt with by #559, #608, #609, #611.

@jclark jclark closed this as completed Sep 26, 2020
@jclark jclark removed this from the Swan Lake September preview milestone Sep 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area/Lang Relates to the Ballerina language specification Type/Improvement Enhancement to language design
Projects
None yet
Development

No branches or pull requests

2 participants