From 0af4dad5830fa1ebb7958dbcf5dd7ede5104189e Mon Sep 17 00:00:00 2001 From: Nadeeshan96 Date: Fri, 7 Jul 2023 12:42:29 +0530 Subject: [PATCH 1/2] Improve StopHandler BBE --- examples/stop-handler/stop_handler.client.out | 1 - examples/stop-handler/stop_handler.md | 10 +++++++--- examples/stop-handler/stop_handler.server.out | 10 ++++------ 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/examples/stop-handler/stop_handler.client.out b/examples/stop-handler/stop_handler.client.out index c9034a00e2..08c1a4bde7 100644 --- a/examples/stop-handler/stop_handler.client.out +++ b/examples/stop-handler/stop_handler.client.out @@ -1,3 +1,2 @@ -# Invoke the service using cURL to add a fruit item. $ curl http://localhost:9090/addToBasket -d 'Guava' ["Apple", "Orange", "Guava"] diff --git a/examples/stop-handler/stop_handler.md b/examples/stop-handler/stop_handler.md index 4bea2219d6..4fec17bebe 100644 --- a/examples/stop-handler/stop_handler.md +++ b/examples/stop-handler/stop_handler.md @@ -1,10 +1,14 @@ # `StopHandler` -The `StopHandler` registers a function that will be called during the graceful shutdown. -This example demonstrates how to register a function that will be executed at the end of the program. +A `StopHandler` is a function called during graceful shutdown, registered at runtime with a module. +This example demonstrates how to register a `StopHandler` that will be executed at the end of the program. ::: code stop_handler.bal ::: -::: out stop_handler.client.out ::: +Navigate to the directory that contains the 'stop_handler.bal' file, and run the 'bal run' command. ::: out stop_handler.server.out ::: + +Invoke the service by executing the following cURL command in a new terminal to add a fruit item. + +::: out stop_handler.client.out ::: diff --git a/examples/stop-handler/stop_handler.server.out b/examples/stop-handler/stop_handler.server.out index 2b049db64c..191e06e938 100644 --- a/examples/stop-handler/stop_handler.server.out +++ b/examples/stop-handler/stop_handler.server.out @@ -1,10 +1,8 @@ -# Navigate to the directory that contains the -# 'stop_handler.bal' file, and run the 'bal run' command below. - $ bal run stop_handler.bal - -# Send the interrupt signal SIGINT to terminate the current process. -Ctrl+c initial items in fruit basket: ["Apple","Orange"] + +# Invoke the service using cURL command as mentioned below in a new terminal. after adding a fruit item: ["Apple","Orange","Guava"] + +# Send the interrupt signal SIGINT (Ctrl+C) to terminate the current process. after removing all fruit items: [] From 209879962d55c11597655d01919da02a852f8180 Mon Sep 17 00:00:00 2001 From: Nadeeshan96 Date: Tue, 11 Jul 2023 15:07:11 +0530 Subject: [PATCH 2/2] Address PR review comments --- examples/stop-handler/stop_handler.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/stop-handler/stop_handler.md b/examples/stop-handler/stop_handler.md index 4fec17bebe..7cccce26c3 100644 --- a/examples/stop-handler/stop_handler.md +++ b/examples/stop-handler/stop_handler.md @@ -1,6 +1,6 @@ # `StopHandler` -A `StopHandler` is a function called during graceful shutdown, registered at runtime with a module. +A `StopHandler` is a function that is registered at runtime with a module and invoked during graceful shutdown. This example demonstrates how to register a `StopHandler` that will be executed at the end of the program. ::: code stop_handler.bal :::