Skip to content

Instantly share code, notes, and snippets.

View TharmiganK's full-sized avatar

Krishnananthalingam Tharmigan TharmiganK

  • WSO2
  • Sri Lanka
View GitHub Profile
@TharmiganK
TharmiganK / main.bal
Created July 25, 2023 04:46
ballerina_oom
public function main() {
string[] arr = [];
while true {
arr.push("value");
}
}
@TharmiganK
TharmiganK / netty-static-error.txt
Last active July 25, 2023 08:57
Stacktrace for the error caused in the static image with netty
java.lang.UnsatisfiedLinkError: failed to load the required native library
at io.netty.handler.ssl.OpenSsl.ensureAvailability(OpenSsl.java:601)
at io.netty.handler.ssl.SslContext.newClientContextInternal(SslContext.java:831)
at io.netty.handler.ssl.SslContextBuilder.build(SslContextBuilder.java:615)
at io.ballerina.stdlib.http.transport.contractimpl.common.ssl.SSLHandlerFactory.createHttp2TLSContextForClient(SSLHandlerFactory.java:360)
at io.ballerina.stdlib.http.transport.contractimpl.sender.HttpClientChannelInitializer.configureSslForHttp2(HttpClientChannelInitializer.java:207)
at io.ballerina.stdlib.http.transport.contractimpl.sender.HttpClientChannelInitializer.initChannel(HttpClientChannelInitializer.java:139)
at io.ballerina.stdlib.http.transport.contractimpl.sender.HttpClientChannelInitializer.initChannel(HttpClientChannelInitializer.java:75)
at io.netty.channel.ChannelInitializer.initChannel(ChannelInitializer.java:129)
at io.nett
@TharmiganK
TharmiganK / conference_model.bal
Last active July 28, 2023 04:44
Conference model in Ballerina
# Represents a conference
#
# + id - The id of the conference
# + name - The name of the conference
public type Conference record {|
readonly int id;
string name;
|};
# Represents a conference request
@TharmiganK
TharmiganK / conference_db_client.bal
Last active July 28, 2023 05:47
Conference Ballerina DB client
import ballerinax/java.jdbc;
import ballerina/sql;
import ballerina/http;
import ballerinax/h2.driver as _;
# Represents the configuration of the h2 database
#
# + user - The user of the database
# + password - The password of the database
# + dbName - The file path of the database
@TharmiganK
TharmiganK / errors.bal
Created July 28, 2023 04:53
Internal server error response
import ballerina/http;
# Represents a Error Detail
#
# + message - The message of the error
# + cause - The cause of the error
public type ErrorDetail record {|
string message;
string cause;
|};
@TharmiganK
TharmiganK / conference_service.bal
Last active July 28, 2023 05:24
Conference Service Ballerina
import ballerina/http;
import ballerina/mime;
configurable string countryServiceUrl = ?;
configurable H2dbConfigs dbConfigs = ?;
service class ConferenceService {
*http:Service;
final ConferenceDBClient conferenceDBClient;
@TharmiganK
TharmiganK / main.bal
Last active August 2, 2023 04:54
Conference Service Main
import ballerina/log;
import ballerina/http;
import ballerina/lang.runtime;
configurable int conferenceServicePort = ?;
public function main() returns error? {
http:Listener conferenceListener = check new (conferenceServicePort);
log:printInfo("Starting the listener...");
// Attach the service to the listener.
@TharmiganK
TharmiganK / Config.toml
Created July 28, 2023 05:19
Configuration required to run Conference Service
conferenceServicePort = 8102
countryServiceUrl = "http://localhost:9000"
# The database related configs
[dbConfigs]
dbName = "conferencedb"
user = "admin"
password = "admin"
@TharmiganK
TharmiganK / requests.http
Created July 28, 2023 07:17
Sample Requests to test the Conference Service
### Add a new conference
POST http://localhost:8102/conferences
Content-Type: application/json
{
"name": "WSO2Con"
}
### Retrive all conferences
GET http://localhost:8102/conferences
@TharmiganK
TharmiganK / run.sh
Created August 1, 2023 06:52
Script to run the application
#!/bin/bash
echo "time = $(date +"%Y-%m-%dT%H:%M:%S.%3N%:z") level = INFO module = tharmigan/conference_service message = Executing the Ballerina application"
if [ "$1" = "graalvm" ];
then
./target/bin/conference_service_ballerina
else
java -jar ./target/bin/conference_service_ballerina.jar
fi