You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2020/12/01 08:54:36 UTC
[GitHub] [flink-statefun] tzulitai opened a new pull request #182: [FLINK-20334] Introduce module YAML format version 3.0 and function endpoint templating
tzulitai opened a new pull request #182:
URL: https://github.com/apache/flink-statefun/pull/182
This PR adds a module YAML format version, 3.0, which supports function endpoint templating.
With 3.0, users define function endpoints like so:
```
endpoints:
## An endpoint url template for all function types under namespace "com.foo.bar"
- endpoint:
meta:
kind: http
spec:
typename:
namespace: com.foo.bar
urlPathTemplate: http://bar.foo.com/{typename.function}
maxNumBatchRequests: 1000
timeouts:
call: 5mins
read: 10seconds
## An endpoint url specifically for the function type "(com.foo.bar, hello-world)"
- endpoint:
meta:
kind: http
spec:
typename:
namespace: com.foo.bar
function: hello-world
urlPathTemplate: http://bar.foo.com/some/specific/path
```
Endpoint URL templates that have been defined for specific types (fully specifying both namespace and function name) will have precedence other ones that have been widely defined for a namespace.
## Implementation notes
The main changes required to enable function templating (besides implementing the JSON parser for the new format) was the following:
- fd361ca In the Java SDK, allow binding `StatefulFunctionProvider` per namespace. Providers bound for specific function types have higher precedence.
- 42cdb52 Logic of resolving the `StatefulFunctionProvider` to use has been updated in the `PredefinedFunctionLoader`.
- 326b56a to 6c2ae2f covers the main work around introducing the new YAML format. Function endpoint specifications are represented by `FunctionEndpointSpec`, with an HTTP implementation `HttpFunctionEndpointSpec`. A new type of function provider `TemplatedHttpFunctionProvider` is used for instantiating `RequestReplyFunction`s based on the parsed `HttpFunctionEndpointSpec`.
- 45f9efb to 1d83341 updates all examples and E2E tests to use module YAML format version 3.0.
## Testing this change
The E2E `ExactlyOnceWithRemoteFnE2E` has been updated to use function endpoint templating, so a CI pass would verify the feature end-to-end.
----------------------------------------------------------------
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
[GitHub] [flink-statefun] igalshilman commented on a change in pull request #182: [FLINK-20334] Introduce module YAML format version 3.0 and function endpoint templating
Posted by GitBox <gi...@apache.org>.
igalshilman commented on a change in pull request #182:
URL: https://github.com/apache/flink-statefun/pull/182#discussion_r533338407
##########
File path: statefun-examples/statefun-async-python-example/statefun/module.yaml
##########
@@ -12,20 +12,23 @@
# 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.
-version: "1.0"
+version: "3.0"
module:
meta:
type: remote
spec:
- functions:
- - function:
+ endpoints:
+ - endpoint:
meta:
kind: http
- type: example/greeter
spec:
- endpoint: http://python-worker:8000/statefun
+ typename:
+ namespace: example
+ function: greeter
Review comment:
As discussed offline, this needs to match the current term `type`.
##########
File path: statefun-flink/statefun-flink-core/src/main/java/org/apache/flink/statefun/flink/core/StatefulFunctionsUniverse.java
##########
@@ -85,7 +87,14 @@ public StatefulFunctionsUniverse(MessageFactoryKey messageFactoryKey) {
public void bindFunctionProvider(FunctionType functionType, StatefulFunctionProvider provider) {
Objects.requireNonNull(functionType);
Objects.requireNonNull(provider);
- putAndThrowIfPresent(functions, functionType, provider);
+ putAndThrowIfPresent(specificFunctionProviders, functionType, provider);
+ }
+
+ @Override
+ public void bindFunctionProvider(String namespace, StatefulFunctionProvider provider) {
Review comment:
@tzulitai, what do you feel about adding a `FunctionTypeNamespaceSelector` type to the SDk,
and make that method:
`bindFunctionProvider(FunctionTypeNamespaceSelector typeSelector, StatefulFunctionProvider provider)` ?
This will communicate the intention a bit better, and make it more extensible for overloading in the future (for example add a `FunctionTypeNamespacePrefixSelector`)
----------------------------------------------------------------
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
[GitHub] [flink-statefun] tzulitai closed pull request #182: [FLINK-20334] Introduce module YAML format version 3.0 and function endpoint templating
Posted by GitBox <gi...@apache.org>.
tzulitai closed pull request #182:
URL: https://github.com/apache/flink-statefun/pull/182
----------------------------------------------------------------
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
[GitHub] [flink-statefun] tzulitai commented on pull request #182: [FLINK-20334] Introduce module YAML format version 3.0 and function endpoint templating
Posted by GitBox <gi...@apache.org>.
tzulitai commented on pull request #182:
URL: https://github.com/apache/flink-statefun/pull/182#issuecomment-737725858
Thanks for the comments @igalshilman.
I addressed your comments with one minor difference:
instead of calling it `FunctionTypeNamespaceSelector`, I found that `FunctionTypeNamespaceMatcher` made more sense.
Basically, it conveys that if a message's target function matches the provided matcher, then that function provider will be used.
The same for a potential `FunctionTypeNamespacePrefixMatcher` in the future.
----------------------------------------------------------------
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