You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2019/11/11 08:58:29 UTC

[GitHub] [pulsar] Anonymitaet commented on a change in pull request #5593: [Docs] Add admin api docs of Pulsar Functions

Anonymitaet commented on a change in pull request #5593: [Docs] Add admin api docs of Pulsar Functions
URL: https://github.com/apache/pulsar/pull/5593#discussion_r344610637
 
 

 ##########
 File path: site2/docs/admin-api-functions.md
 ##########
 @@ -0,0 +1,545 @@
+---
+id: admin-api-functions
+title: Manage Functions
+sidebar_label: Functions
+---
+
+**Pulsar Functions** are lightweight compute processes that
+
+* consume messages from one or more Pulsar topics
+* apply a user-supplied processing logic to each message
+* publish the results of the computation to another topic
+
+Functions can be managed via the following methods.
+
+Method | Description
+---|---
+**Admin CLI** | The [`functions`](reference-pulsar-admin.md#functions) command of the [`pulsar-admin`](reference-pulsar-admin.md) tool.
+**REST API** |The `/admin/v3/functions` endpoint of the admin {@inject: rest:REST:/} API.
+**Java Admin API**| The `functions` method of the {@inject: javadoc:PulsarAdmin:/admin/org/apache/pulsar/client/admin/PulsarAdmin} object in the [Java API](client-libraries-java.md).
+
+## Function resources
+
+You can perform the following operations on functions.
+
+### Create
+
+You can create a Pulsar function in cluster mode (deploy it on a Pulsar cluster) using Admin CLI, REST API or Java Admin API.
+
+#### Admin CLI
+
+Use the [`create`](reference-pulsar-admin.md#functions-create) subcommand. 
+
+**Example**
+
+```shell
+$ pulsar-admin functions create \
+  --tenant public \
+  --namespace default \
+  --name (the name of Pulsar Functions) \
+  --inputs test-input-topic \
+  --output persistent://public/default/test-output-topic \
+  --classname org.apache.pulsar.functions.api.examples.ExclamationFunction \
+  --jar /examples/api-examples.jar
+```
+
+#### REST API
+
+{@inject: endpoint|POST|/admin/v3/functions/{tenant}/{namespace}/{functionName}
+
+#### Java Admin API
+
+```java
+FunctionConfig functionConfig = new FunctionConfig();
+functionConfig.setTenant(tenant);
+functionConfig.setNamespace(namespace);
+functionConfig.setName(functionName);
+functionConfig.setRuntime(FunctionConfig.Runtime.JAVA);
+functionConfig.setParallelism(1);
+functionConfig.setClassName("org.apache.pulsar.functions.api.examples.ExclamationFunction");
+functionConfig.setProcessingGuarantees(FunctionConfig.ProcessingGuarantees.ATLEAST_ONCE);
+functionConfig.setTopicsPattern(sourceTopicPattern);
+functionConfig.setSubName(subscriptionName);
+functionConfig.setAutoAck(true);
+functionConfig.setOutput(sinkTopic);
+admin.functions().createFunction(functionConfig, fileName);
+```
+
+### Update
+
+You can update a Pulsar function that has been deployed to a Pulsar cluster using Admin CLI, REST API or Java Admin API.
+
+#### Admin CLI
+
+Use the [`update`](reference-pulsar-admin.md#functions-update) subcommand. 
+
+**Example**
+
+```shell
+$ pulsar-admin functions update \
+  --tenant public \
+  --namespace default \
+  --name (the name of Pulsar Functions) \
+  --output persistent://public/default/update-output-topic \
+  # other options
+```
+
+#### REST Admin API
+
+{@inject: endpoint|PUT|/admin/v3/functions/{tenant}/{namespace}/{functionName}
+
+#### Java Admin API
+
+```java
+FunctionConfig functionConfig = new FunctionConfig();
+functionConfig.setTenant(tenant);
+functionConfig.setNamespace(namespace);
+functionConfig.setName(functionName);
+functionConfig.setRuntime(FunctionConfig.Runtime.JAVA);
+functionConfig.setParallelism(1);
+functionConfig.setClassName("org.apache.pulsar.functions.api.examples.ExclamationFunction");
+UpdateOptions updateOptions = new UpdateOptions();
+updateOptions.setUpdateAuthData(updateAuthData);
+admin.functions().updateFunction(functionConfig, userCodeFile, updateOptions);
+```
+
+### Start 1
+
+You can start a stopped function instance using Admin CLI, REST API or Java Admin API.
 
 Review comment:
   ```suggestion
   You can start a stopped function instance with `instance-id` using Admin CLI, REST API or Java Admin API.
   ```

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


With regards,
Apache Git Services