Apache Flink Stateful Functions 3.x - Invoke functions with gRPC

141 Views Asked by At

I am learning Apache Flink (And Stateful Functions) for my upcoming works. I am able to create a sample project with custom ingress, router and egress. All work as expected.

However, I realized that I am using HTTP to invoke functions. Here is my module.yaml

kind: io.statefun.endpoints.v2/http
spec:
  functions: my.statefun.fn/*
  urlPathTemplate: http://statefun-demo-functions:1108
  transport:
    type: io.statefun.transports.v1/async
---
kind: my.statefun.ingress/amq-ingress
spec:
  queue:
    - Profile
---
kind: my.statefun.ingress/egress
spec:
  port: 8091
  topics:
    - Profile

At the official document of Flink, it stated:

Function invocations happen through an HTTP / gRPC protocol and go through a service that routes invocation requests to any available endpoint, for example a Kubernetes (load-balancing) service, the AWS request gateway for Lambda, etc. Because invocations are self-contained (contain message, state, access to timers, etc.) the target functions can be treated like any stateless application

Therefore, I am trying to implement the invocation by gRPC instead of HTTP. But I can't find any clue of using gRPC anywhere over the internet. I went through the source code of Apache Flink and I found a package call flink-rpc at: https://github.com/apache/flink/tree/master/flink-rpc

But still have no idea how to use it properly. I am just guessing, after use protoc with gRPC plugin to generate necessary files, I can implement the gRPC server and handler on the stateful function but at the module.yaml , I can't find the proper kind to make the invocation works on gRPC.

Have anyone archived gRPC invocation before? You help is much appreciated.

0

There are 0 best solutions below