This is an automated email from the ASF dual-hosted git repository.

mmerli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-pulsar.git


The following commit(s) were added to refs/heads/master by this push:
     new 884b1d1  Pulsar Functions triggering overview (#1503)
884b1d1 is described below

commit 884b1d1d966eea75bb060eebcfada9d761d20c21
Author: Luc Perkins <lucperk...@gmail.com>
AuthorDate: Tue Apr 10 16:46:41 2018 -0700

    Pulsar Functions triggering overview (#1503)
    
    * Add brief section to overview on processing guarantees
    
    * add new sections to overview
    
    * add basic PF diagram
    
    * add word count diagram
    
    * add two new examples to overview
    
    * add triggering section to overview
    
    * change section ID
---
 site/docs/latest/functions/deployment.md |  4 ++--
 site/docs/latest/functions/overview.md   | 31 ++++++++++++++++++++++++++++---
 2 files changed, 30 insertions(+), 5 deletions(-)

diff --git a/site/docs/latest/functions/deployment.md 
b/site/docs/latest/functions/deployment.md
index 8901347..25c0c2f 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 ffee467..c3cf23d 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:

-- 
To stop receiving notification emails like this one, please contact
mme...@apache.org.

Reply via email to