You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2022/08/12 06:27:55 UTC

[GitHub] [apisix] spacewander commented on a diff in pull request #7634: feat: add openfunction plugin

spacewander commented on code in PR #7634:
URL: https://github.com/apache/apisix/pull/7634#discussion_r944148528


##########
docs/en/latest/plugins/openfunction.md:
##########
@@ -0,0 +1,122 @@
+---
+title: openfunction
+keywords:
+  - APISIX
+  - Plugin
+  - OpenFunction
+  - openfunction
+description: This document contains information about the CNCF OpenFunction Plugin.
+---
+
+<!--
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+-->
+
+## Description
+
+The `openfunction` Plugin is used to integrate APISIX with [CNCF OpenFunction](https://openfunction.dev/) serverless platform.
+
+This Plugin can be configured on a Route and requests will be send to the configured OpenWhish API endpoint as the upstream.
+
+## Attributes
+
+| Name              | Type    | Required | Default | Valid values | Description                                                                                                |
+| ----------------- | ------- | -------- | ------- | ------------ | ---------------------------------------------------------------------------------------------------------- |
+| function_uri      | string  | True     |         |              | function uri. For example, `https://localhost:30858/default/function-sample`.                              |
+| ssl_verify        | boolean | False    | true    |              | When set to `true` verifies the SSL certificate.                                                           |
+| service_token     | string  | False    |         |              | The token format is 'xx:xx' which support basic auth for ingress controller, .                                      |
+| timeout           | integer | False    | 60000ms | [1, 60000]ms | OpenFunction action and HTTP call timeout in ms.                                                              |
+| keepalive         | boolean | False    | true    |              | When set to `true` keeps the connection alive for reuse.                                                   |
+| keepalive_timeout | integer | False    | 60000ms | [1000,...]ms | Time is ms for connection to remain idle without closing.                                                  |
+| keepalive_pool    | integer | False    | 5       | [1,...]      | Maximum number of requests that can be sent on this connection before closing it.                          |
+
+:::note
+
+The `timeout` attribute sets the time taken by the OpenFunction to execute, and the timeout for the HTTP client in APISIX. OpenFunction  calls may take time to pull the runtime image and start the container. So, if the value is set too small, it may cause a large number of requests to fail.
+
+:::
+
+## Enabling the Plugin
+
+Before configuring the Plugin, you need to have OpenFunction running. For details, please refer to [Installation](https://openfunction.dev/docs/getting-started/installation/).

Review Comment:
   ```suggestion
   Before configuring the plugin, you need to have OpenFunction running. For details, please refer to [Installation](https://openfunction.dev/docs/getting-started/installation/).
   ```



##########
docs/en/latest/plugins/openfunction.md:
##########
@@ -0,0 +1,122 @@
+---
+title: openfunction
+keywords:
+  - APISIX
+  - Plugin
+  - OpenFunction
+  - openfunction
+description: This document contains information about the CNCF OpenFunction Plugin.
+---
+
+<!--
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+-->
+
+## Description
+
+The `openfunction` Plugin is used to integrate APISIX with [CNCF OpenFunction](https://openfunction.dev/) serverless platform.
+
+This Plugin can be configured on a Route and requests will be send to the configured OpenWhish API endpoint as the upstream.
+
+## Attributes
+
+| Name              | Type    | Required | Default | Valid values | Description                                                                                                |
+| ----------------- | ------- | -------- | ------- | ------------ | ---------------------------------------------------------------------------------------------------------- |
+| function_uri      | string  | True     |         |              | function uri. For example, `https://localhost:30858/default/function-sample`.                              |
+| ssl_verify        | boolean | False    | true    |              | When set to `true` verifies the SSL certificate.                                                           |
+| service_token     | string  | False    |         |              | The token format is 'xx:xx' which support basic auth for ingress controller, .                                      |
+| timeout           | integer | False    | 60000ms | [1, 60000]ms | OpenFunction action and HTTP call timeout in ms.                                                              |
+| keepalive         | boolean | False    | true    |              | When set to `true` keeps the connection alive for reuse.                                                   |
+| keepalive_timeout | integer | False    | 60000ms | [1000,...]ms | Time is ms for connection to remain idle without closing.                                                  |
+| keepalive_pool    | integer | False    | 5       | [1,...]      | Maximum number of requests that can be sent on this connection before closing it.                          |
+
+:::note
+
+The `timeout` attribute sets the time taken by the OpenFunction to execute, and the timeout for the HTTP client in APISIX. OpenFunction  calls may take time to pull the runtime image and start the container. So, if the value is set too small, it may cause a large number of requests to fail.

Review Comment:
   ```suggestion
   The `timeout` attribute sets the time taken by the OpenFunction to execute, and the timeout for the HTTP client in APISIX. OpenFunction calls may take time to pull the runtime image and start the container. So, if the value is set too small, it may cause a large number of requests to fail.
   ```



##########
apisix/plugins/openfunction.lua:
##########
@@ -0,0 +1,36 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements.  See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License.  You may obtain a copy of the License at
+--
+--     http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+local ngx_encode_base64 = ngx.encode_base64
+local plugin_name, plugin_version, priority = "openfunction", 0.1, -1902
+
+local openfunction_authz_schema = {
+    service_token = {type = "string"}
+}
+
+local function request_processor(conf, ctx, params)
+    local headers = params.headers or {}
+    -- setting authorization headers if not already set
+    if not headers["Authorization"] and conf.authorization

Review Comment:
   Does the header here need to be lower-case? And we need a test case that the user-specific Authorization header has higher priority.



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org