Skip to content

Commit

Permalink
Merge pull request #1421 from ballerina-platform/listener-config
Browse files Browse the repository at this point in the history
Make listener configuration as an included parameter
  • Loading branch information
TharmiganK authored Jan 28, 2025
2 parents b007b50 + 116b3de commit 5d68b71
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 20 deletions.
2 changes: 1 addition & 1 deletion ballerina/Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

[ballerina]
dependencies-toml-version = "2"
distribution-version = "2201.11.0-20241121-075100-c4c87cbc"
distribution-version = "2201.11.0-20250127-101700-a4b67fe5"

[[package]]
org = "ballerina"
Expand Down
2 changes: 1 addition & 1 deletion ballerina/listener_endpoint.bal
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public isolated class Listener {
#
# + listenerConfig - Configurations for FTP listener
# + return - `()` or else an `ftp:Error` upon failure to initialize the listener
public isolated function init(ListenerConfiguration listenerConfig) returns Error? {
public isolated function init(*ListenerConfiguration listenerConfig) returns Error? {
self.config = listenerConfig.clone();
lock {
return initListener(self, self.config);
Expand Down
18 changes: 9 additions & 9 deletions ballerina/tests/listener_endpoint_test.bal
Original file line number Diff line number Diff line change
Expand Up @@ -226,20 +226,20 @@ public function testServerRegisterFailureEmptyUsername() returns error? {

@test:Config {}
public function testServerRegisterFailureInvalidUsername() returns error? {
Listener|Error invalidUsernameServer = new ({
protocol: FTP,
host: "127.0.0.1",
auth: {
Listener|Error invalidUsernameServer = new (
protocol = FTP,
host = "127.0.0.1",
auth = {
credentials: {
username: "ballerina",
password: "wso2"
}
},
port: 21212,
path: "/home/in",
pollingInterval: 2,
fileNamePattern: "(.*).txt"
});
port = 21212,
path = "/home/in",
pollingInterval = 2,
fileNamePattern = "(.*).txt"
);

if invalidUsernameServer is Error {
test:assertEquals(invalidUsernameServer.message(), "Failed to initialize File server connector.");
Expand Down
6 changes: 6 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ This file contains all the notable changes done to the Ballerina Email package t

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Changed

- [Change the listener configuration as an included parameter](https://github.com/ballerina-platform/ballerina-library/issues/7494)

## [2.11.0] - 2024-08-20

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion docs/spec/spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ An insecure FTP listener can be initialized by providing the mandatory `protocol
#
# + listenerConfig - Configurations for FTP listener
# + return - `()` or else an `ftp:Error` upon failure to initialize the listener
public isolated function init(ListenerConfiguration listenerConfig) returns Error?;
public isolated function init(*ListenerConfiguration listenerConfig) returns Error?;
```
#### 4.2.2. Secure Listener
A secure listener can be initialized by providing `ftp:SFTP` as the protocol and by providing `ftp:Credentials`
Expand Down
16 changes: 8 additions & 8 deletions examples/covid19-stat-publisher/processor/processor.bal
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ ftp:ClientConfiguration sftpClientConfig = {
auth: authConfig
};

listener ftp:Listener secureRemoteServer = check new({
protocol: ftp:SFTP,
host: "localhost",
auth: authConfig,
port: 21213,
pollingInterval: 2,
fileNamePattern: "(.*).csv"
});
listener ftp:Listener secureRemoteServer = check new(
protocol = ftp:SFTP,
host = "localhost",
auth = authConfig,
port = 21213,
pollingInterval = 2,
fileNamePattern = "(.*).csv"
);

service "Covid19UpdateDownloader" on secureRemoteServer {

Expand Down

0 comments on commit 5d68b71

Please sign in to comment.