Skip to content

Commit

Permalink
Merge pull request #1287 from dilanSachi/change-workflows
Browse files Browse the repository at this point in the history
Isolate the FTP listener
  • Loading branch information
NipunaRanasinghe authored Aug 6, 2024
2 parents 0ead2eb + 2b2aae8 commit 54a1cc9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
2 changes: 1 addition & 1 deletion ballerina/Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ modules = [
[[package]]
org = "ballerina"
name = "observe"
version = "1.2.0"
version = "1.2.3"
dependencies = [
{org = "ballerina", name = "jballerina.java"}
]
Expand Down
22 changes: 14 additions & 8 deletions ballerina/listener_endpoint.bal
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
// specific language governing permissions and limitations
// under the License.

import ballerina/jballerina.java;
import ballerina/log;
import ballerina/task;
import ballerina/jballerina.java;

# Represents a service listener that monitors the FTP location.
public class Listener {
public isolated class Listener {

private handle EMPTY_JAVA_STRING = java:fromString("");
private ListenerConfiguration config = {};
Expand All @@ -30,8 +30,10 @@ public 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? {
self.config = listenerConfig;
return initListener(self, self.config);
self.config = listenerConfig.clone();
lock {
return initListener(self, self.config);
}
}

# Starts the `ftp:Listener`.
Expand Down Expand Up @@ -91,13 +93,17 @@ public class Listener {
}

isolated function internalStart() returns error? {
self.jobId = check task:scheduleJobRecurByFrequency(new Job(self), self.config.pollingInterval);
lock {
self.jobId = check task:scheduleJobRecurByFrequency(new Job(self), self.config.pollingInterval);
}
}

isolated function stop() returns error? {
var id = self.jobId;
if id is task:JobId {
check task:unscheduleJob(id);
lock {
var id = self.jobId;
if id is task:JobId {
check task:unscheduleJob(id);
}
}
}

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]

### Fixed

- [Isolated the `ftp:Listener`](https://github.com/ballerina-platform/module-ballerina-ftp/pull/1287)

## [2.10.1] - 2024-07-24

## Added
Expand Down

0 comments on commit 54a1cc9

Please sign in to comment.