You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by tz...@apache.org on 2020/02/10 03:43:36 UTC

[flink-statefun] 07/09: [FLINK-15955] Add an HttpFunctionSpec

This is an automated email from the ASF dual-hosted git repository.

tzulitai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink-statefun.git

commit ae9b5dbd72e84d514b8c2edc54a9176a3d51b07b
Author: Igal Shilman <ig...@gmail.com>
AuthorDate: Fri Feb 7 18:18:40 2020 +0100

    [FLINK-15955] Add an HttpFunctionSpec
---
 .../flink/core/jsonmodule/FunctionSpec.java        | 32 +++++++++++++
 .../flink/core/jsonmodule/HttpFunctionSpec.java    | 53 ++++++++++++++++++++++
 .../statefun/flink/core/jsonmodule/Pointers.java   |  4 ++
 3 files changed, 89 insertions(+)

diff --git a/statefun-flink/statefun-flink-core/src/main/java/org/apache/flink/statefun/flink/core/jsonmodule/FunctionSpec.java b/statefun-flink/statefun-flink-core/src/main/java/org/apache/flink/statefun/flink/core/jsonmodule/FunctionSpec.java
new file mode 100644
index 0000000..097c3cf
--- /dev/null
+++ b/statefun-flink/statefun-flink-core/src/main/java/org/apache/flink/statefun/flink/core/jsonmodule/FunctionSpec.java
@@ -0,0 +1,32 @@
+/*
+ * 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.
+ */
+package org.apache.flink.statefun.flink.core.jsonmodule;
+
+import org.apache.flink.statefun.sdk.FunctionType;
+
+public interface FunctionSpec {
+
+  FunctionType functionType();
+
+  Kind kind();
+
+  enum Kind {
+    HTTP,
+    GRPC
+  }
+}
diff --git a/statefun-flink/statefun-flink-core/src/main/java/org/apache/flink/statefun/flink/core/jsonmodule/HttpFunctionSpec.java b/statefun-flink/statefun-flink-core/src/main/java/org/apache/flink/statefun/flink/core/jsonmodule/HttpFunctionSpec.java
new file mode 100644
index 0000000..f37358f
--- /dev/null
+++ b/statefun-flink/statefun-flink-core/src/main/java/org/apache/flink/statefun/flink/core/jsonmodule/HttpFunctionSpec.java
@@ -0,0 +1,53 @@
+/*
+ * 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.
+ */
+package org.apache.flink.statefun.flink.core.jsonmodule;
+
+import java.net.URI;
+import java.util.List;
+import java.util.Objects;
+import org.apache.flink.statefun.sdk.FunctionType;
+
+public final class HttpFunctionSpec implements FunctionSpec {
+  private final FunctionType functionType;
+  private final URI endpoint;
+  private final List<String> states;
+
+  public HttpFunctionSpec(FunctionType functionType, URI endpoint, List<String> states) {
+    this.functionType = Objects.requireNonNull(functionType);
+    this.endpoint = Objects.requireNonNull(endpoint);
+    this.states = Objects.requireNonNull(states);
+  }
+
+  @Override
+  public FunctionType functionType() {
+    return functionType;
+  }
+
+  @Override
+  public Kind kind() {
+    return Kind.HTTP;
+  }
+
+  public URI endpoint() {
+    return endpoint;
+  }
+
+  public List<String> states() {
+    return states;
+  }
+}
diff --git a/statefun-flink/statefun-flink-core/src/main/java/org/apache/flink/statefun/flink/core/jsonmodule/Pointers.java b/statefun-flink/statefun-flink-core/src/main/java/org/apache/flink/statefun/flink/core/jsonmodule/Pointers.java
index 9745036..fb25ac1 100644
--- a/statefun-flink/statefun-flink-core/src/main/java/org/apache/flink/statefun/flink/core/jsonmodule/Pointers.java
+++ b/statefun-flink/statefun-flink-core/src/main/java/org/apache/flink/statefun/flink/core/jsonmodule/Pointers.java
@@ -39,9 +39,13 @@ public final class Pointers {
   // -------------------------------------------------------------------------------------
 
   public static final class Functions {
+    public static final JsonPointer META_KIND = JsonPointer.compile("/function/meta/kind");
     public static final JsonPointer META_TYPE = JsonPointer.compile("/function/meta/type");
     public static final JsonPointer FUNCTION_HOSTNAME = JsonPointer.compile("/function/spec/host");
+    public static final JsonPointer FUNCTION_ENDPOINT =
+        JsonPointer.compile("/function/spec/endpoint");
     public static final JsonPointer FUNCTION_PORT = JsonPointer.compile("/function/spec/port");
+    public static final JsonPointer FUNCTION_STATES = JsonPointer.compile("/function/spec/states");
   }
 
   // -------------------------------------------------------------------------------------