merlimat closed pull request #1503: Pulsar Functions triggering overview
URL: https://github.com/apache/incubator-pulsar/pull/1503
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/site/docs/latest/functions/deployment.md 
b/site/docs/latest/functions/deployment.md
index 8901347039..25c0c2fc9c 100644
--- a/site/docs/latest/functions/deployment.md
+++ b/site/docs/latest/functions/deployment.md
@@ -104,9 +104,9 @@ $ bin/pulsar-admin functions update \
   --functionConfigFile function-config.yaml
 ```
 
-## Triggering functions
+## Triggering Pulsar Functions {#triggering}
 
-Whether a Pulsar Function is running in [local run](#local-run) or 
[cluster](#cluster-mode), you can **trigger** the function at any time using 
the command line. Triggering a function means that you send a message with a 
specific value to the function.
+If a Pulsar Function is running in [cluster mode](#cluster-mode), you can 
**trigger** it at any time using the command line. Triggering a function means 
that you send a message with a specific value to the function and get the 
function's output (if any) via the command line.
 
 {% include admonition.html type="info" content="Triggering a function is 
ultimately no different from invoking a function by producing a message on one 
of the function's input topics. The [`pulsar-admin functions 
trigger`](../../CliTools#pulsar-admin-functions-trigger) command is essentially 
a convenient mechanism for sending messages to functions without needing to use 
the [`pulsar-client`](../../CliTools#pulsar-client) tool or a language-specific 
client library." %}
 
diff --git a/site/docs/latest/functions/overview.md 
b/site/docs/latest/functions/overview.md
index ffee467d65..c3cf23d65d 100644
--- a/site/docs/latest/functions/overview.md
+++ b/site/docs/latest/functions/overview.md
@@ -62,8 +62,6 @@ If you were to implement the classic word count example using 
Pulsar Functions,
 
 ![Pulsar Functions word count example](/img/pulsar-functions-word-count.png)
 
-Here, sentences are produced on the `sentences` topic. The Pulsar Function 
listens on that topic and whenever a message arrives it splits the sentence up 
into individual words and increments a [counter](#counters) for each word every 
time that word is encountered. The value of that counter is then available to 
all [instances](#parallelism) of the function.
-
 If you were writing the function in [Java](../api#java) using the [Pulsar 
Functions SDK for Java](../api#java-sdk), you could write the function like 
this...
 
 ```java
@@ -193,7 +191,7 @@ Pulsar Functions can currently be written in 
[Java](../../functions/api#java) an
 * SerDe (built-in vs. custom)
 * Pulsar messages are always just bytes, but Pulsar Functions handles data 
types for you *unless* you need custom types
 
-## Function context {#context}
+### Function context {#context}
 
 Each Pulsar Function created using the [Pulsar Functions SDK](#sdk) has access 
to a context object that both provides:
 
@@ -347,6 +345,33 @@ public class ConfigMapFunction implements Function<String, 
Void> {
 }
 ```
 
+### Triggering Pulsar Functions {#triggering}
+
+Pulsar Functions running in [cluster mode](#cluster-mode) can be 
[triggered](../deployment#triggering) via the [command line](#cli). With 
triggering you can easily pass a specific value to a function and get the 
function's return value *without* needing to worry about creating a client, 
sending a message to the right input topic, etc. Triggering can be very useful 
for---but is by no means limited to---testing and debugging purposes.
+
+{% include admonition.html type="info" content="Triggering a function is 
ultimately no different from invoking a function by producing a message on one 
of the function's input topics. The [`pulsar-admin functions 
trigger`](../../CliTools#pulsar-admin-functions-trigger) command is essentially 
a convenient mechanism for sending messages to functions without needing to use 
the [`pulsar-client`](../../CliTools#pulsar-client) tool or a language-specific 
client library." %}
+
+Let's take an example Pulsar Function written in Python (using the [native 
interface](../api#python-native)) that simply reverses string inputs:
+
+```python
+def process(input):
+    return input[::-1]
+```
+
+If that function were running in a Pulsar cluster, it could be triggered like 
this:
+
+```bash
+$ bin/pulsar-admin functions trigger \
+  --tenant sample \
+  --namespace ns1 \
+  --name reverse-func \
+  --triggerValue "snoitcnuf raslup ot emoclew"
+```
+
+That should return `welcome to pulsar functions` as the console output.
+
+{% include admonition.html type="success" content="Instead of passing in a 
string via the CLI, you can also trigger a Pulsar Function with the contents of 
a file using the `--triggerFile` flag." %}
+
 ## Processing guarantees {#guarantees}
 
 The Pulsar Functions feature provides three different messaging semantics that 
you can apply to any function:


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to