Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve StopHandler BBE #4674

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
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: []