Skip to content

Commit

Permalink
Merge pull request #4674 from Nadeeshan96/master-fix-runtime-bbes
Browse files Browse the repository at this point in the history
Improve `StopHandler` BBE
  • Loading branch information
warunalakshitha authored Jul 18, 2023
2 parents f91bba4 + 2098799 commit 945a44b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
1 change: 0 additions & 1 deletion examples/stop-handler/stop_handler.client.out
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
# Invoke the service using cURL to add a fruit item.
$ curl http://localhost:9090/addToBasket -d 'Guava'
["Apple", "Orange", "Guava"]
10 changes: 7 additions & 3 deletions examples/stop-handler/stop_handler.md
Original file line number Diff line number Diff line change
@@ -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 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 :::

::: 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 :::
10 changes: 4 additions & 6 deletions examples/stop-handler/stop_handler.server.out
Original file line number Diff line number Diff line change
@@ -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: []

0 comments on commit 945a44b

Please sign in to comment.