Skip to content
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions ballerina/Ballerina.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
org = "ballerinax"
name = "mysql"
version = "1.16.1"
version = "1.16.2"
authors = ["Ballerina"]
keywords = ["database", "client", "network", "SQL", "RDBMS", "MySQL"]
repository = "https://github.com/ballerina-platform/module-ballerinax-mysql"
Expand All @@ -15,11 +15,11 @@ graalvmCompatible = true
[[platform.java21.dependency]]
groupId = "io.ballerina.stdlib"
artifactId = "mysql-native"
version = "1.16.1"
path = "../native/build/libs/mysql-native-1.16.1.jar"
version = "1.16.2"
path = "../native/build/libs/mysql-native-1.16.2-SNAPSHOT.jar"
Comment on lines +18 to +19
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Version mismatch between declared version and JAR path.

The version field is "1.16.2" but the path references mysql-native-1.16.2-SNAPSHOT.jar. This inconsistency could cause confusion during dependency resolution or release processes.

Consider aligning these values:

  • If this is a snapshot/development build, update version to "1.16.2-SNAPSHOT"
  • If this is a release, ensure the path references the non-SNAPSHOT JAR
🤖 Prompt for AI Agents
In `@ballerina/Ballerina.toml` around lines 18 - 19, The version and JAR path are
inconsistent: the version key "version" is set to "1.16.2" while the path
references "mysql-native-1.16.2-SNAPSHOT.jar"; update either the version field
to "1.16.2-SNAPSHOT" or change the path to point to "mysql-native-1.16.2.jar" so
the "version" value and the JAR filename in the "path" string match; ensure you
update the "version" key and/or the path literal accordingly to reflect whether
this is a snapshot or a release.


[[platform.java21.dependency]]
groupId = "io.ballerina.stdlib"
artifactId = "sql-native"
version = "1.16.0"
path = "./lib/sql-native-1.16.0.jar"
version = "1.17.1"
path = "./lib/sql-native-1.17.1.jar"
2 changes: 1 addition & 1 deletion ballerina/CompilerPlugin.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ id = "mysql-compiler-plugin"
class = "io.ballerina.stdlib.mysql.compiler.MySQLCompilerPlugin"

[[dependency]]
path = "../compiler-plugin/build/libs/mysql-compiler-plugin-1.16.1.jar"
path = "../compiler-plugin/build/libs/mysql-compiler-plugin-1.16.2-SNAPSHOT.jar"
76 changes: 58 additions & 18 deletions ballerina/Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ dependencies = [
{org = "ballerina", name = "log"}
]

[[package]]
org = "ballerina"
name = "avro"
version = "1.2.0"
dependencies = [
{org = "ballerina", name = "jballerina.java"}
]

[[package]]
org = "ballerina"
name = "cache"
Expand All @@ -44,7 +52,7 @@ dependencies = [
[[package]]
org = "ballerina"
name = "crypto"
version = "2.9.0"
version = "2.10.1"
dependencies = [
{org = "ballerina", name = "jballerina.java"},
{org = "ballerina", name = "time"}
Expand All @@ -56,7 +64,7 @@ modules = [
[[package]]
org = "ballerina"
name = "data.jsondata"
version = "1.1.0"
version = "1.1.3"
dependencies = [
{org = "ballerina", name = "jballerina.java"},
{org = "ballerina", name = "lang.object"}
Expand All @@ -80,7 +88,7 @@ modules = [
[[package]]
org = "ballerina"
name = "http"
version = "2.14.0"
version = "2.14.9"
scope = "testOnly"
dependencies = [
{org = "ballerina", name = "auth"},
Expand Down Expand Up @@ -130,7 +138,7 @@ modules = [
[[package]]
org = "ballerina"
name = "jwt"
version = "2.15.0"
version = "2.15.1"
scope = "testOnly"
dependencies = [
{org = "ballerina", name = "cache"},
Expand All @@ -147,7 +155,6 @@ dependencies = [
org = "ballerina"
name = "lang.__internal"
version = "0.0.0"
scope = "testOnly"
dependencies = [
{org = "ballerina", name = "jballerina.java"},
{org = "ballerina", name = "lang.object"}
Expand Down Expand Up @@ -185,7 +192,6 @@ dependencies = [
org = "ballerina"
name = "lang.int"
version = "0.0.0"
scope = "testOnly"
dependencies = [
{org = "ballerina", name = "jballerina.java"},
{org = "ballerina", name = "lang.__internal"},
Expand Down Expand Up @@ -255,7 +261,6 @@ dependencies = [
org = "ballerina"
name = "log"
version = "2.12.0"
scope = "testOnly"
dependencies = [
{org = "ballerina", name = "io"},
{org = "ballerina", name = "jballerina.java"},
Expand All @@ -266,7 +271,7 @@ dependencies = [
[[package]]
org = "ballerina"
name = "mime"
version = "2.12.0"
version = "2.12.1"
scope = "testOnly"
dependencies = [
{org = "ballerina", name = "io"},
Expand All @@ -278,7 +283,7 @@ dependencies = [
[[package]]
org = "ballerina"
name = "oauth2"
version = "2.14.0"
version = "2.14.1"
scope = "testOnly"
dependencies = [
{org = "ballerina", name = "cache"},
Expand All @@ -292,15 +297,15 @@ dependencies = [
[[package]]
org = "ballerina"
name = "observe"
version = "1.5.0"
version = "1.5.1"
dependencies = [
{org = "ballerina", name = "jballerina.java"}
]

[[package]]
org = "ballerina"
name = "os"
version = "1.10.0"
version = "1.10.1"
scope = "testOnly"
dependencies = [
{org = "ballerina", name = "io"},
Expand All @@ -322,7 +327,7 @@ modules = [
[[package]]
org = "ballerina"
name = "sql"
version = "1.16.0"
version = "1.17.1"
dependencies = [
{org = "ballerina", name = "io"},
{org = "ballerina", name = "jballerina.java"},
Expand Down Expand Up @@ -360,7 +365,7 @@ modules = [
[[package]]
org = "ballerina"
name = "time"
version = "2.7.0"
version = "2.8.0"
dependencies = [
{org = "ballerina", name = "jballerina.java"}
]
Expand All @@ -371,7 +376,7 @@ modules = [
[[package]]
org = "ballerina"
name = "url"
version = "2.6.0"
version = "2.6.1"
scope = "testOnly"
dependencies = [
{org = "ballerina", name = "jballerina.java"}
Expand All @@ -381,7 +386,6 @@ dependencies = [
org = "ballerina"
name = "uuid"
version = "1.10.0"
scope = "testOnly"
dependencies = [
{org = "ballerina", name = "crypto"},
{org = "ballerina", name = "jballerina.java"},
Expand Down Expand Up @@ -423,21 +427,57 @@ modules = [
[[package]]
org = "ballerinax"
name = "cdc"
version = "1.0.1"
version = "1.2.0"
dependencies = [
{org = "ballerina", name = "crypto"},
{org = "ballerina", name = "data.jsondata"},
{org = "ballerina", name = "io"},
{org = "ballerina", name = "jballerina.java"},
{org = "ballerinai", name = "observe"}
{org = "ballerina", name = "log"},
{org = "ballerinai", name = "observe"},
{org = "ballerinax", name = "kafka"}
]
modules = [
{org = "ballerinax", packageName = "cdc", moduleName = "cdc"}
]

[[package]]
org = "ballerinax"
name = "confluent.cavroserdes"
version = "1.0.2"
dependencies = [
{org = "ballerina", name = "avro"},
{org = "ballerina", name = "jballerina.java"},
{org = "ballerinai", name = "observe"},
{org = "ballerinax", name = "confluent.cregistry"}
]

[[package]]
org = "ballerinax"
name = "confluent.cregistry"
version = "0.4.3"
dependencies = [
{org = "ballerina", name = "jballerina.java"}
]

[[package]]
org = "ballerinax"
name = "kafka"
version = "4.6.3"
dependencies = [
{org = "ballerina", name = "crypto"},
{org = "ballerina", name = "jballerina.java"},
{org = "ballerina", name = "time"},
{org = "ballerina", name = "uuid"},
{org = "ballerinai", name = "observe"},
{org = "ballerinax", name = "confluent.cavroserdes"},
{org = "ballerinax", name = "confluent.cregistry"}
]

[[package]]
org = "ballerinax"
name = "mysql"
version = "1.16.1"
version = "1.16.2"
dependencies = [
{org = "ballerina", name = "crypto"},
{org = "ballerina", name = "file"},
Expand Down
16 changes: 10 additions & 6 deletions ballerina/cdc_listener.bal
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,21 @@ import ballerinax/cdc;
public isolated class CdcListener {
*cdc:Listener;

private final map<string> & readonly config;
private final map<anydata> & readonly config;
private boolean isStarted = false;
private boolean hasAttachedService = false;

# Initializes the MySQL listener with the given configuration.
#
# + config - The configuration for the MySQL connector
public isolated function init(*MySqlListenerConfiguration config) {
map<string> configMap = {};
map<string> debeziumConfigs = {};
cdc:populateDebeziumProperties({
engineName: config.engineName,
offsetStorage: config.offsetStorage,
internalSchemaStorage: config.internalSchemaStorage,
options: config.options
}, configMap);
}, debeziumConfigs);
cdc:populateDatabaseConfigurations({
connectorClass: config.database.connectorClass,
hostname: config.database.hostname,
Expand All @@ -47,9 +47,13 @@ public isolated class CdcListener {
excludedTables: config.database.excludedTables,
includedColumns: config.database.includedColumns,
excludedColumns: config.database.excludedColumns
}, configMap);
populateMySqlConfigurations(config.database, configMap);
self.config = configMap.cloneReadOnly();
}, debeziumConfigs);
populateMySqlConfigurations(config.database, debeziumConfigs);
map<anydata> listenerConfigs = {
...debeziumConfigs
};
listenerConfigs["livenessInterval"] = config.livenessInterval;
self.config = listenerConfigs.cloneReadOnly();
}

# Attaches a CDC service to the MySQL listener.
Expand Down
103 changes: 103 additions & 0 deletions ballerina/tests/listener_liveness_test.bal
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
// Copyright (c) 2026, WSO2 LLC. (https://www.wso2.com).
//
// WSO2 LLC. licenses this file to you under the Apache License,
// Version 2.0 (the "License"); you may not use this file except
// in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

import ballerina/lang.runtime;
import ballerina/test;
import ballerinax/cdc;

@test:Config {
groups: ["liveness"]
}
function testLivenessBeforeListenerStart() returns error? {
CdcListener mysqlListener = new ({
database: {
username: cdcUsername,
password: cdcPassword,
port
},
options: {
snapshotMode: cdc:NO_DATA
}
});
check mysqlListener.attach(testService);
boolean liveness = check cdc:isLive(mysqlListener);
test:assertFalse(liveness, "Liveness check passes even before listener starts");
}

@test:Config {
groups: ["liveness"]
}
function testLivenessWithStartedListener() returns error? {
CdcListener mysqlListener = new ({
database: {
username: cdcUsername,
password: cdcPassword,
port: cdcPort
},
options: {
snapshotMode: cdc:NO_DATA
}
});
check mysqlListener.attach(testService);
check mysqlListener.'start();
boolean liveness = check cdc:isLive(mysqlListener);
test:assertTrue(liveness, "Liveness fails for a started listener");
check mysqlListener.gracefulStop();
}

@test:Config {
groups: ["liveness"]
}
function testLivenessAfterListenerStop() returns error? {
CdcListener mysqlListener = new ({
database: {
username: cdcUsername,
password: cdcPassword,
port: cdcPort
},
options: {
snapshotMode: cdc:NO_DATA
}
});
check mysqlListener.attach(testService);
check mysqlListener.'start();
check mysqlListener.gracefulStop();
boolean liveness = check cdc:isLive(mysqlListener);
test:assertFalse(liveness, "Liveness check passes after the listener has stopped");
}

@test:Config {
groups: ["liveness"]
}
function testLivenessWithoutReceivingEvents() returns error? {
CdcListener mysqlListener = new ({
database: {
username: cdcUsername,
password: cdcPassword,
port: cdcPort
},
options: {
snapshotMode: cdc:NO_DATA
},
livenessInterval: 5.0
});
check mysqlListener.attach(testService);
check mysqlListener.'start();
runtime:sleep(10);
boolean liveness = check cdc:isLive(mysqlListener);
test:assertFalse(liveness, "Liveness check passes even after not receiving events within the liveness interval");
check mysqlListener.gracefulStop();
}
5 changes: 5 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,13 @@ subprojects {
ballerinaStdLibs "io.ballerina.stdlib:mysql.driver-ballerina:${stdlibMysqlDriverVersion}"

ballerinaStdLibs "io.ballerina.stdlib:random-ballerina:${stdlibRandomVersion}"
ballerinaStdLibs "io.ballerina.lib:avro-ballerina:${stdlibAvroVersion}"
ballerinaStdLibs "io.ballerina.lib:cdc-ballerina:${stdlibCdcVersion}"
ballerinaStdLibs "io.ballerina.lib:mysql.cdc.driver-ballerina:${stdlibMySQLCdcDriverVersion}"

ballerinaStdLibs "io.ballerina.stdlib:kafka-ballerina:${stdlibKafkaVersion}"
ballerinaStdLibs "io.ballerina.lib:confluent.cavroserdes-ballerina:${stdlibConfluentAvroSerDesVersion}"
ballerinaStdLibs "io.ballerina.lib:confluent.cregistry-ballerina:${stdlibConfluentSchemaRegistryVersion}"
}
}

Expand Down
Loading