sjwiesman commented on a change in pull request #263: URL: https://github.com/apache/flink-statefun/pull/263#discussion_r697510518
########## File path: docs/content/docs/modules/http-endpoint.md ########## @@ -0,0 +1,206 @@ +--- +title: 'HTTP Function Endpoint' +weight: 2 +type: docs +--- +<!-- +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. +--> + +# HTTP Function Endpoint + +A HTTP Function Endpoint component defines the endpoint URL that the Stateful Functions runtime should connect to for +invoking a given function, or for a more dynamic deployment, functions within a specified namespace. + +Below is an example of an HTTP endpoint definition in an application's module configuration: + +{{< tabs "8951ef0a-cdd4-40d1-bda8-dec1299aaf41" >}} +{{< tab "v2 (latest)" >}} +```yaml +kind: io.statefun.endpoints.v2/http +spec: + functions: com.example/* + urlPathTemplate: https://bar.foo.com:8080/{function.name} + transport: + timeouts: + call: 1 min + read: 10 sec + write: 10 sec +``` +{{< /tab >}} +{{< tab "v1" >}} +```yaml +kind: io.statefun.endpoints.v1/http +spec: + functions: com.example/* + urlPathTemplate: https://bar.foo.com:8080/{function.name} + timeouts: + call: 1 min + read: 10 sec + write: 10 sec +``` +{{< /tab >}} +{{< /tabs >}} + +In this example, an endpoint for a function within the logical namespace `com.example` is declared. +The runtime will invoke all functions under this namespace with the endpoint URL template. + +### URL Template + +The URL template name may contain template parameters that are filled in based on the function's specific type. +In the example below, a message sent to message type `com.example/greeter` will be sent to `http://bar.foo.com/greeter`. + +```yaml +spec: + functions: com.example/* + urlPathTemplate: https://bar.foo.com/{function.name} +``` + +Templating parameterization works well with load balancers and service gateways. +Suppose `http://bar.foo.com` was an [NGINX](https://www.nginx.com/) server, you can use the different paths to physical systems. Users may now deploy some functions on Kubernetes, others AWS Lambda, while others still on physical servers. + +{{< img src="/fig/dispatch.png" alt="function dispatch" width="75%" >}} + +### Transport + +Switching between different transport clients is supported since `v2` of HTTP function endpoint definitions. + +The transport client to use is specified using `spec.transport.type`. If not specified, by default, Stateful Functions uses [OkHttp](https://square.github.io/okhttp/). + +All fields under `spec.transport` is used as the properties to configure the transport client. For example, the example below configures various timeout settings for the default `OkHttp` transport: + +```yaml +spec: + transport: + timeouts: + call: 1 min + read: 30 sec + write: 20 sec +``` + +#### Asynchronous HTTP transport (Beta) + +Alternatively, Stateful Functions also ships a transport option based on asynchronous non-blocking IO, implemented with [Netty](https://netty.io/). Review comment: ```suggestion Alternatively, Stateful Functions also ships a transport option based on asynchronous non-blocking IO, implemented with [Netty](https://netty.io/). This transport enables much higher resource utilization, higher throughput, and lower remote function invocation latency. ``` -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
