Skip to main content
Filter by
Sorted by
Tagged with
40 votes
4 answers
5k views

How does Ballerina differ from other languages?

Ballerina is a general purpose, concurrent and strongly typed programming language with both textual and graphical syntaxes for better integration Is Ballerina an interpreted language? How to ...
Abimaran Kugathasan's user avatar
7 votes
2 answers
348 views

How to implement inheritance in Ballerina

I can see the following description in Ballerina docs regarding type equivalence and inheritance. Ballerina is based on type equivalence, rather than type inheritance. The type system in Ballerina ...
Samitha Chathuranga's user avatar
6 votes
3 answers
598 views

How do I read an int from command line in Ballerina?

any choice = io:readln("Enter choice 1 - 5: "); I cannot seem to cast the input to an int. Both check and match gives the same error var intChoice = <int>choice; match intChoice { int ...
Samisa's user avatar
  • 1,072
6 votes
2 answers
120 views

Can we ignore case when doing ballerina regexp matches

I am trying to match regardless of case. regexp:RegExp pattern = re `(ax|test)is$`; Should match both Axis or axis.
Niveathika's user avatar
  • 1,445
5 votes
2 answers
283 views

Error in passing parameters to sql query in Ballerina

I'm developing a simple ballerina application which retrives the email of a given name(cntname). string sqlString = "SELECT email FROM CONTACTS WHERE Name=?"; // Retrieve employee data by invoking ...
Krishi H's user avatar
  • 536
5 votes
1 answer
619 views

How to get the index of an object in Ballerina Array?

How can I get the index of an object in a Ballerina array in an efficient way? Is there any inbuilt function to do that?
Rivindu Madushan's user avatar
4 votes
2 answers
1k views

How to convert a string to an int?

According to type conversion example a string to int conversion is made with int.convert(). However in Ballerina 1.0.0 that doesn't work: $ ballerina version Ballerina 1.0.0 Language specification ...
user272735's user avatar
  • 10.6k
4 votes
4 answers
1k views

Ballerina For Loop

Is there a for loop in ballerina like the for loop in java. I could only find foreach and while loop in the Ballerina Documentation. for(int i=0; i<10; i++){ //some logic }
Dan.M's user avatar
  • 81
4 votes
1 answer
131 views

Unexpected "compound assignment not allowed with nullable operands" compilation error

In the code below I have correctly narrowed the type of str to string. However the second += compound operator gives me a compilation error: ERROR compound assignment not allowed with nullable ...
user272735's user avatar
  • 10.6k
4 votes
1 answer
197 views

Threads and Reactive Programming in Ballerina

I have just started to follow ballerina by reading https://ballerina.io/ documentation. when I try to run Hello World Parallel then I have no idea how internally it works? import ballerina/io; ...
Nafaz M N M's user avatar
  • 1,678
4 votes
1 answer
701 views

Is Ballerina ready for production? [closed]

I find Ballerina a great solution to create an api gateway layer. Is it ready for production? Is someone using it in production? Thanks Gianni
Gianni Bortolo Bossini's user avatar
4 votes
1 answer
71 views

How to correctly compare the types of two variables in Ballerina and ensure they have the same type?

I'm working with Ballerina and attempting to compare the types of two variables to ensure they have the same type. The code snippet looks like this: typedesc type1 = typeof input1; typedesc type2 = ...
Nuvindu Nirmana's user avatar
4 votes
1 answer
233 views

Setting Up Language Server Protocol (LSP) for Ballerina in Neovim

I'm trying to use Ballerina with neovim editor and would like to use the Language Server Protocol (LSP) with it. However, It is unclear to me from the documentation here (https://github.com/ballerina-...
Poorna's user avatar
  • 329
4 votes
1 answer
878 views

How to Convert JSON to record or map type in Ballerina with JSON key names with spaces

I'm getting a JSON from [1], due to the naming of the keys in the json I was unable to straightaway use either of the 2 approches in hadling JSON in ballerina: Approach 1: Work with json values ...
Suleka_28's user avatar
  • 2,859
4 votes
1 answer
381 views

How to use JWT with Ballerina

I read about JWT and i think i understand how it works, but when things come to ballerina examples i don't understand anything: How do i set the algorithm which i want to use along with JWT and the ...
Under_Ice's user avatar
  • 147
4 votes
1 answer
175 views

What does the arrow -> operator do in Ballerina?

I'm new to this language and just started back at it after a few months and have a relatively basic question. I'm having some confusion understanding the arrow -> operator in it. In the examples ...
Rahul P's user avatar
  • 2,643
4 votes
2 answers
642 views

Ballerina appending elements to end of an array

How can i append element to end of an array directly other than using following code. string[] array = ["1","2"]; array[lengthof-1] = "3";
Dan.M's user avatar
  • 81
4 votes
2 answers
320 views

How to set up http proxy for ballerina?

Is it possible to configure ballerina command to use http proxy when searching for the packages? Doing ballerina search twitter fails with the following error message: Connection to the remote host ...
Marko's user avatar
  • 31.1k
4 votes
2 answers
215 views

Deploy Ballerina as AWS Lambda functions

I've written a basic Ballerina function and attempted to deploy as AWS Lambda. AWS reports a permissions error when I try to add the Lambda layer (using the published ARN link - https://ballerina.io/...
Jeff Swan's user avatar
4 votes
2 answers
398 views

How to create a list of lists in Ballerina?

I need to create a list of lists in Ballerina. In java, I would simply say List<List<String>>. How do I do this in ballerina? I have the following code. int[][] arr = [[1,2,3], [4,5,...
Dinu94's user avatar
  • 165
4 votes
1 answer
103 views

ballerina.io SQL LIKE statement

i am currently trying to execute the following SQL statement in ballerina.io against a MariaDB. Plan SQL: select * FROM testDB where test LIKE '%BA%'; I get a result set with all data. ballerina.io: ...
Martin 's user avatar
4 votes
1 answer
351 views

How to write a test case in Ballerina?

I'm a newbie to Ballerina integration language and need a way to write a test case. Following is my initial code. package samples.foo.bar; import ballerina.lang.system; function main (string[] args)...
Chanuka Ranaba's user avatar
4 votes
1 answer
153 views

Comparing Performance of Ballerina vs. Spring Boot: Should I Expect Consistency Across Different Environments?

I'm currently conducting a research project comparing the performance of Ballerina programming language with Spring Boot. I'm using JMeter tests to analyze various performance metrics. One concern I ...
Ricardo Coelho's user avatar
3 votes
3 answers
860 views

Convert String to Json in Ballerina

Is there a way to convert string to json in Ballerina ? I found this PR - Add jsons:parse() method to get a JSON from a string where it says adding support to parse string to json, but couldn't find ...
ThisaruG's user avatar
  • 3,372
3 votes
1 answer
411 views

How do you get the type of a variable in Ballerina?

How do you get the type of a variable in Ballerina? I know that boolean checks are possible such as these below: import ballerina/io; public function main() { any x = "This is a test"; io:...
Rahul P's user avatar
  • 2,643
3 votes
3 answers
414 views

How to terminate Ballerina program

I wanna stop ballerina program in the middle of some logic. How can I stop a running program in ballerina using code? I'm looking for something equivalent to System.exit(0) in java.
Isuru Gunawardana's user avatar
3 votes
4 answers
582 views

How do I do a type check in ballerina

I tried if(string? myStr) but that gives a syntax error in the editor. How do I do a type check in Ballerina ?
nuwanbando's user avatar
3 votes
2 answers
236 views

Deploying the Ballerina integration example in a Docker container

On the Ballerina Quick Tour page, there is an example on deploying a previously created integration microservice (which is supposed to send a Tweet) within in a docker container. However, that part ...
Chathura Kulasinghe's user avatar
3 votes
1 answer
84 views

How to enable debug logging for Ballerina test cases?

I need to enable debug-level logging for my Ballerina test cases. What's the simplest way to do this?
MOHAMED SABTHAR's user avatar
3 votes
1 answer
73 views

Build size of a simple program

I do not understand why the size of a very simple compiled program is around 8Mb. This does not include the JVM I assume? Here is a simple Ballerina program import ballerina/io; type Score [string, ...
Rudolf's user avatar
  • 127
3 votes
2 answers
147 views

Getting the status of a transaction without callbacks in Ballerina

In Ballerina we can identify whether a transaction was successful within "onCommit" and "onAbort" functions we provide. But this takes us away from the current method. I want to be able to verify ...
Erandi Ganepola's user avatar
3 votes
1 answer
504 views

Ballerina : Idle timeout triggered before initiating inbound response

I am executing Task appointment in a ballerina project which runs every 10 minutes. It works fine for roughly an hour but when the execution time reaches 2 hours it gives me an error. Following is the ...
Madhuka Harith's user avatar
3 votes
1 answer
172 views

How to pass an endpoint as an parameter to a function in Ballerina

I'm using 'wso2/ftp' package for some file transferring process and have an ftp:Client endpoint as follows in my main .bal file. endpoint ftp:Client server1 { protocol: ftp:FTP, host:<...
Nipuna Dilhara's user avatar
3 votes
1 answer
35 views

Is there a way to return an isolated variable from an isolated function?

import ballerina/http; isolated json[] outputIso = []; service on new http:Listener(9090) { isolated resource function get invictScanList() returns json|error { return outputIso; } } ...
MOHAMED SABTHAR's user avatar
3 votes
1 answer
44 views

How to interpret Query, Mutation and Subscription operations in a Ballerina GraphQL service?

Most GraphQL libraries use the schema definition language(SDL) to define the types of a GraphQL service, like this: type Query { greeting: String! } type Mutation { setName(name: String!): String!...
Dimuthu Madushan's user avatar
3 votes
1 answer
578 views

Ballerina, Using Json Response from REST-API

My professor wants me to write a little tutorial on how to deploy Ballerina services. So I'm trying to learn it. I'm using Version 1.2 and I'm a bit overwhelmed by the concept of taint checking and ...
Jan-Ole Hübner's user avatar
3 votes
2 answers
209 views

Ballerina annotation processing doesn't work as expected

I am trying to implement a simple annotation processor with ballerina (jBallerina-1.0.5 on MacOS Catalina). In this example, I need to: Iterate through available resource functions of a given service ...
Channa Jayamuni's user avatar
3 votes
2 answers
201 views

How to invoke ballerina service in windows cmd

I'm running my services in ballerina composer, then I'm using Windows cmd to invoke the service using the curl but cmd is complaining that curl is not a recognized command. How could I do it in cmd? ...
MabutaBee's user avatar
3 votes
1 answer
80 views

How to exclude a module from test coverage calculations for a Ballerina package?

I have a Ballerina package with multiple modules, and one of them consists mostly of autogenerated code for which I currently do not have tests. When I generate test coverage report, the overall ...
Tharmigan Krishnananthalingam's user avatar
3 votes
2 answers
62 views

How to convert a data of `byte[]` coming from RabbitMQ broker into a record type in Ballerina

I'm using RabbitMQ module in ballerina package along with a server and a client. In the client I'm receiving the content as a byte[] which needs to be converted to a CustomerDetails record type before ...
Kode Factory's user avatar
3 votes
1 answer
71 views

What is the purpose of using `@display` annotation in Ballerina?

In Ballerina, I've come across code that uses the @display annotation in service and record parameters. Can someone please clarify what the @display annotation is used for and provide some use cases ...
Nuvindu Nirmana's user avatar
3 votes
2 answers
71 views

Error when overriding common field (included field) in a ballerina record

I'm getting an error when trying to override a common field (included field) in one record with a different type in ballerina. Please refer to the below code. type Vehicle record { string color; ...
LochanaJ's user avatar
  • 144
3 votes
1 answer
132 views

Should input sanitisation also be considered in Ballerina SQL?

I'm currently working with parameterised queries in Ballerina. int id = 10; int age = 12; sql:ParameterizedQuery query = `SELECT * FROM students WHERE id < ${id} AND age > ${age}`; I want to ...
Mindula's user avatar
  • 221
3 votes
1 answer
124 views

How to increase the allocated memory for Ballerina programs?

I need to run a Ballerina program using the bal command with increased memory. By default, a maximum of 1024 MB of memory is allocated for a Ballerina program. I am trying to run a quite large ...
Malintha Ranasinghe's user avatar
3 votes
1 answer
141 views

Unable to pass dynamic values to config records

I have a requirement to pass a JWT client assertion to the oauth2 client credentials grant config record. I'm passing the parameter as the optional parameter. But this parameter has to be generated ...
Thishani Lucas's user avatar
3 votes
1 answer
100 views

Ballerina integrator and Elasticsearch

i am working on my bachelor degree project and i have to use the Ballerina integrator middle-ware. Now i need to make a service which will be able to index data coming to ballerina into ...
Under_Ice's user avatar
  • 147
3 votes
2 answers
224 views

Ballerina: How do connect with SMTP server and send email?

I am looking at WSO2's Ballerina programming language. I don't see the module or package that allows the ballerina code to call SMTP server and send email. The only thing close to SMTP is the Gmail ...
chj915's user avatar
  • 37
3 votes
1 answer
64 views

How to pass a value to a method in an isolated object in Ballerina?

I have an implementation of a queue in Ballerina that is supposed to work in a concurrency environment as shown below. However, it generates the error invalid attempt to transfer a value into a 'lock' ...
Nipuna Fernando's user avatar
3 votes
1 answer
108 views

Test failure when mocking nil result

When trying to run a test that mocks a nil return value, I'm getting the following error. Any idea? function f1() returns string?|error { return f2(); } function f2() returns string?|error { ...
Bondowe's user avatar
  • 75
3 votes
2 answers
739 views

Ballerina "type 'json' does not support field access for assignment"

I'm using the Ballerina language to create a RESTful web service for order management in an online retail store as instructed in here. In the resource function which handles HTTP PUT requests, there ...
Hiran Hasanka's user avatar

1
2 3 4 5
13