-
Notifications
You must be signed in to change notification settings - Fork 755
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
Ballerina configurable doesn't support fields with nil type #37045
Comments
@HindujaB Did you get a chance to discuss this with the team? |
But, from the above use-cases, we should be able to support the following record fields. type MySQLConnection record {|
string? user = ();
string? password = ();
|};
configurable MySQLConnection conn = ?; Only cases where the field is provided with a default value. This can be done as an improvement. As a workaround, we can use optional fields instead of the nilable fields to get similar behavior. But, the limitation is that we can't have a default value for those fields. public type ConnectionConfig record {|
string baseUrl;
http:OAuth2RefreshTokenGrantConfig|http:BearerTokenConfig clientConfig;
http:ClientSecureSocket secureSocketConfig?;
string httpVersion = "1.1";
http:ClientHttp1Settings http1Settings = {};
http:ClientHttp2Settings http2Settings = {};
decimal timeout = 60;
string forwarded = "disable";
http:FollowRedirects followRedirects?;
http:PoolConfiguration poolConfig?;
http:CacheConfig cache = {};
http:Compression compression = http:COMPRESSION_AUTO;
http:CircuitBreakerConfig circuitBreaker?;
http:RetryConfig retryConfig?;
// http:CookieConfig cookieConfig?; // non-anydata
http:ResponseLimitConfigs responseLimits = {};
|}; |
I think we should able to support above use case where we have a configurable variable with union type including nil and default value. In that case restrictions of TOML syntax will not an effect. Since nil is part of anydata it is also comply with the spec. |
Description:
An example code snippet.
This gives,
Describe your problem(s)
The above issue is affecting all
ballerinax
connector config parameters. When a developer wants to set a config record as configurable, it gives the above error. Let me takeballerinax/salesforce
connector as an example.salesforce:init
salesforce:ConnectionConfig
There were two issues I have identified.
http:CookieConfig
has an object type calledPersistentCookieHandler
. Ballerina configurable doesn't support object types. We can removehttp:CookieConfig
from allballerinax
connector init records as it is not required. But what if a user wanted to create a configurable to initializeballerina/http
connectorinit (string url, *ClientConfiguration config)
?I am working on a design to create connections for connectors. This issue is affecting coming up with a clean approach. Appreciate your input.
Describe your solution(s)
Related Issues (optional):
Suggested Labels (optional):
Suggested Assignees (optional):
The text was updated successfully, but these errors were encountered: