igalshilman commented on a change in pull request #2:
URL: 
https://github.com/apache/flink-statefun-playground/pull/2#discussion_r596842944



##########
File path: java/shopping-cart/Dockerfile
##########
@@ -0,0 +1,19 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more

Review comment:
       I think we can avoid having a separate Dockerfile by mounting the 
`module.json` into the `apache/flink-statefun:3.0.0` container. 
   For example, I'm currently working on a Python greeter example in there I'm 
using:
   
   ```
   worker:
       image: apache/flink-statefun:3.0
       expose:
         - "6121"
         - "6122"
       depends_on:
         - master
         - kafka-broker
       links:
         - "master:master"
         - "kafka-broker:kafka-broker"
       environment:
         - ROLE=worker
         - MASTER_HOST=master
       volumes:
         - ./checkpoint-dir:/checkpoint-dir
         - ./module.yaml:/opt/statefun/modules/greeter/module.yaml # <-------- 
mount it here
   
   ```
   
   Since this example, is currently not runnable , then I'll suggest simply 
dropping this Dockerfile for now. 
   What do you think?

##########
File path: 
java/shopping-cart/src/main/java/org/apache/flink/statefun/examples/shoppingcart/Expose.java
##########
@@ -0,0 +1,104 @@
+/*
+ * 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.examples.shoppingcart;
+
+import static io.undertow.UndertowOptions.ENABLE_HTTP2;
+
+import io.undertow.Undertow;
+import io.undertow.server.HttpHandler;
+import io.undertow.server.HttpServerExchange;
+import io.undertow.util.Headers;
+import java.util.Objects;
+import java.util.concurrent.CompletableFuture;
+import org.apache.flink.statefun.sdk.java.StatefulFunctionSpec;
+import org.apache.flink.statefun.sdk.java.StatefulFunctions;
+import org.apache.flink.statefun.sdk.java.handler.RequestReplyHandler;
+import org.apache.flink.statefun.sdk.java.slice.Slice;
+import org.apache.flink.statefun.sdk.java.slice.Slices;
+
+public class Expose {
+
+  public static void main(String... args) {

Review comment:
       Super slick 💯 

##########
File path: java/shopping-cart/pom.xml
##########
@@ -0,0 +1,82 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+         xmlns="http://maven.apache.org/POM/4.0.0";
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
+
+    <artifactId>statefun-shopping-cart-example</artifactId>

Review comment:
       can the artifact name be `shopping-cart` (to match the enclosing 
directory)
   

##########
File path: 
java/shopping-cart/src/main/java/org/apache/flink/statefun/examples/shoppingcart/InventoryFn.java
##########
@@ -0,0 +1,70 @@
+/*
+ * 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.examples.shoppingcart;
+
+import static org.apache.flink.statefun.examples.shoppingcart.Messages.*;
+import static 
org.apache.flink.statefun.examples.shoppingcart.Messages.ItemAvailability.*;
+
+import java.util.concurrent.CompletableFuture;
+import org.apache.flink.statefun.sdk.java.AddressScopedStorage;
+import org.apache.flink.statefun.sdk.java.Context;
+import org.apache.flink.statefun.sdk.java.StatefulFunction;
+import org.apache.flink.statefun.sdk.java.TypeName;
+import org.apache.flink.statefun.sdk.java.ValueSpec;
+import org.apache.flink.statefun.sdk.java.message.Message;
+import org.apache.flink.statefun.sdk.java.message.MessageBuilder;
+
+final class InventoryFn implements StatefulFunction {
+
+  static final TypeName TYPE = 
TypeName.typeNameFromString("com.example.fns/inventory");
+
+  static final ValueSpec<Integer> INVENTORY = 
ValueSpec.named("inventory").withIntType();
+
+  @Override
+  public CompletableFuture<Void> apply(Context context, Message message) {
+    AddressScopedStorage storage = context.storage();
+    int quantity = storage.get(INVENTORY).orElse(0);
+    if (message.is(RESTOCK_ITEM_TYPE)) {
+      RestockItem restock = message.as(RESTOCK_ITEM_TYPE);
+      int newQuantity = quantity + restock.getQuantity();
+      storage.set(INVENTORY, newQuantity);
+    } else if (message.is(REQUEST_ITEM_TYPE)) {
+      RequestItem request = message.as(REQUEST_ITEM_TYPE);
+      int requestQuantity = request.getQuantity();
+
+      ItemAvailability itemAvailability;
+
+      if (quantity >= requestQuantity) {
+        storage.set(INVENTORY, quantity - requestQuantity);
+        itemAvailability = new ItemAvailability(Status.INSTOCK, 
requestQuantity);
+      } else {
+        itemAvailability = new ItemAvailability(Status.OUTOFSTOCK, 
requestQuantity);
+      }
+
+      context
+          .caller()
+          .ifPresent(

Review comment:
       I think that the `ifPresent` might be a bit confusing to folks. If you 
known that there is a caller in this case,
   how about calling `.get()` or `.getOrElse( () -> throw new 
IllegalStateException("There should always be a caller in this example")).
    

##########
File path: java/shopping-cart/pom.xml
##########
@@ -0,0 +1,82 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+         xmlns="http://maven.apache.org/POM/4.0.0";
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
+
+    <artifactId>statefun-shopping-cart-example</artifactId>
+    <groupId>org.apache.flink</groupId>
+    <modelVersion>4.0.0</modelVersion>
+    <version>0.1</version>
+
+    <properties>
+        
<protoc-jar-maven-plugin.version>3.11.1</protoc-jar-maven-plugin.version>
+        <statefun.version>2.3-SNAPSHOT</statefun.version>
+        <untertow.version>2.2.5.Final</untertow.version>
+        <jackson-databind.version>2.10.1</jackson-databind.version>
+        <junit.version>4.12</junit.version>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.flink</groupId>
+            <artifactId>statefun-sdk-java</artifactId>
+            <version>${statefun.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>io.undertow</groupId>
+            <artifactId>undertow-core</artifactId>
+            <version>${untertow.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.fasterxml.jackson.core</groupId>
+            <artifactId>jackson-databind</artifactId>
+            <version>${jackson-databind.version}</version>
+            <scope>compile</scope>
+        </dependency>
+
+
+        <!-- test -->
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>${junit.version}</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+    <build>

Review comment:
       Do you use Protobuf in this example?
   Can you remove that?

##########
File path: 
java/shopping-cart/src/main/java/org/apache/flink/statefun/examples/shoppingcart/InventoryFn.java
##########
@@ -0,0 +1,70 @@
+/*
+ * 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.examples.shoppingcart;
+
+import static org.apache.flink.statefun.examples.shoppingcart.Messages.*;
+import static 
org.apache.flink.statefun.examples.shoppingcart.Messages.ItemAvailability.*;
+
+import java.util.concurrent.CompletableFuture;
+import org.apache.flink.statefun.sdk.java.AddressScopedStorage;
+import org.apache.flink.statefun.sdk.java.Context;
+import org.apache.flink.statefun.sdk.java.StatefulFunction;
+import org.apache.flink.statefun.sdk.java.TypeName;
+import org.apache.flink.statefun.sdk.java.ValueSpec;
+import org.apache.flink.statefun.sdk.java.message.Message;
+import org.apache.flink.statefun.sdk.java.message.MessageBuilder;
+
+final class InventoryFn implements StatefulFunction {
+
+  static final TypeName TYPE = 
TypeName.typeNameFromString("com.example.fns/inventory");
+
+  static final ValueSpec<Integer> INVENTORY = 
ValueSpec.named("inventory").withIntType();
+
+  @Override
+  public CompletableFuture<Void> apply(Context context, Message message) {
+    AddressScopedStorage storage = context.storage();
+    int quantity = storage.get(INVENTORY).orElse(0);
+    if (message.is(RESTOCK_ITEM_TYPE)) {
+      RestockItem restock = message.as(RESTOCK_ITEM_TYPE);
+      int newQuantity = quantity + restock.getQuantity();
+      storage.set(INVENTORY, newQuantity);
+    } else if (message.is(REQUEST_ITEM_TYPE)) {
+      RequestItem request = message.as(REQUEST_ITEM_TYPE);
+      int requestQuantity = request.getQuantity();
+
+      ItemAvailability itemAvailability;

Review comment:
       nit: can the item availably be made `final`. I find it easier to read 
trough the if-else like that. 

##########
File path: java/shopping-cart/src/main/statefun-config-sample/module.yaml
##########
@@ -0,0 +1,72 @@
+# 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.
+version: "3.0"
+module:
+  meta:
+    type: remote
+  spec:
+    endpoints:
+      - endpoint:
+          meta:
+            kind: http
+          spec:
+            typename:
+              namespace: example
+              type: greeter
+            urlPathTemplate: 
http://shopping-cart-service.statefun.svc:8080/statefun
+            maxNumBatchRequests: 500
+            timeouts:
+              call: 2min
+    ingresses:
+      - ingress:
+          meta:
+            type: statefun.kafka.io/universal-ingress
+            id: example.com/shopping-cart-updates
+          spec:
+            address: cp-cp-kafka.confluent-platform.svc:9092
+            consumerGroupId: my-group-id
+            topics:
+              - topic: shopping-cart-updates
+                # ? Unclear which type to use if multiple cart-related messages
+                # (AddToCart/RemoveFromCart/ClearCart) are multiplexed in one 
topic. THe Python example uses a protobuf
+                # envelope, but we decided to migrate this example to JSON. 
Type for generic JSON?
+                typeUrl: com.example/AddToCart
+                targets:
+                  - com.example.fns/user-shopping-cart
+      - ingress:
+          meta:
+            type: statefun.kafka.io/universal-ingress
+            id: com.example/inventory-updates
+          spec:
+            address: cp-cp-kafka.confluent-platform.svc:9092
+            consumerGroupId: my-group-id
+            topics:
+              - topic: inventory-updates
+                # ? Unclear which type to use if multiple inventory-related 
messages
+                # (RestockItem/RemoveItem/ReserveItemExternal) are multiplexed 
in one topic. The Python example uses a
+                # protobuf envelope, but we decided to migrate this example to 
JSON. Type for generic JSON?
+                typeUrl: com.example/RestockItem
+                targets:
+                  - com.example.fns/inventory
+    egresses:
+      - egress:
+          meta:
+            type: statefun.kafka.io/generic-egress
+            id: com.example/receipts
+          spec:
+            address: cp-cp-kafka.confluent-platform.svc:9092

Review comment:
       🙈 

##########
File path: 
java/shopping-cart/src/main/java/org/apache/flink/statefun/examples/shoppingcart/Identifiers.java
##########
@@ -0,0 +1,27 @@
+/*
+ * 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.examples.shoppingcart;
+
+import org.apache.flink.statefun.sdk.java.TypeName;
+
+final class Identifiers {

Review comment:
       nice 👍 , really tidy.

##########
File path: 
java/shopping-cart/src/main/java/org/apache/flink/statefun/examples/shoppingcart/Expose.java
##########
@@ -0,0 +1,104 @@
+/*
+ * 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.examples.shoppingcart;
+
+import static io.undertow.UndertowOptions.ENABLE_HTTP2;
+
+import io.undertow.Undertow;
+import io.undertow.server.HttpHandler;
+import io.undertow.server.HttpServerExchange;
+import io.undertow.util.Headers;
+import java.util.Objects;
+import java.util.concurrent.CompletableFuture;
+import org.apache.flink.statefun.sdk.java.StatefulFunctionSpec;
+import org.apache.flink.statefun.sdk.java.StatefulFunctions;
+import org.apache.flink.statefun.sdk.java.handler.RequestReplyHandler;
+import org.apache.flink.statefun.sdk.java.slice.Slice;
+import org.apache.flink.statefun.sdk.java.slice.Slices;
+
+public class Expose {
+
+  public static void main(String... args) {
+    StatefulFunctionSpec inventoryFn =
+        StatefulFunctionSpec.builder(InventoryFn.TYPE)
+            .withValueSpec(InventoryFn.INVENTORY)
+            .withSupplier(InventoryFn::new)
+            .build();
+
+    StatefulFunctionSpec userShoppingCartFn =
+        StatefulFunctionSpec.builder(UserShoppingCartFn.TYPE)
+            .withValueSpec(UserShoppingCartFn.BASKET)
+            .withSupplier(UserShoppingCartFn::new)
+            .build();
+
+    StatefulFunctions functions = new StatefulFunctions();
+    
functions.withStatefulFunction(inventoryFn).withStatefulFunction(userShoppingCartFn);
+    RequestReplyHandler handler = functions.requestReplyHandler();
+
+    Undertow server =

Review comment:
       Can you please add a small comment here, saying something along the 
lines of `in this example we are using the Undertow http server, but any HTTP 
server/framework will work as-well`?
   It would be mentioned in other examples as-well, but there is also a chance 
that this example will be the first a learner will see.

##########
File path: 
java/shopping-cart/src/main/java/org/apache/flink/statefun/examples/shoppingcart/UserShoppingCartFn.java
##########
@@ -0,0 +1,164 @@
+/*
+ * 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.examples.shoppingcart;
+
+import static 
org.apache.flink.statefun.examples.shoppingcart.Identifiers.RECEIPT_EGRESS;
+import static org.apache.flink.statefun.examples.shoppingcart.Messages.*;
+import static 
org.apache.flink.statefun.examples.shoppingcart.Messages.ItemAvailability.*;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+import java.util.concurrent.CompletableFuture;
+import java.util.stream.Collectors;
+import org.apache.flink.statefun.sdk.java.AddressScopedStorage;
+import org.apache.flink.statefun.sdk.java.Context;
+import org.apache.flink.statefun.sdk.java.StatefulFunction;
+import org.apache.flink.statefun.sdk.java.TypeName;
+import org.apache.flink.statefun.sdk.java.ValueSpec;
+import org.apache.flink.statefun.sdk.java.io.KafkaEgressMessage;
+import org.apache.flink.statefun.sdk.java.message.Message;
+import org.apache.flink.statefun.sdk.java.message.MessageBuilder;
+import org.apache.flink.statefun.sdk.java.types.SimpleType;
+import org.apache.flink.statefun.sdk.java.types.Type;
+
+final class UserShoppingCartFn implements StatefulFunction {
+
+  static final TypeName TYPE = 
TypeName.typeNameFromString("com.example.fns/user-shopping-cart");
+
+  
+  static final ValueSpec<Basket> BASKET = 
ValueSpec.named("basket").withCustomType(Basket.TYPE);
+
+  @Override
+  public CompletableFuture<Void> apply(Context context, Message message) {
+    if (message.is(ADD_TO_CART)) {
+      AddToCart addToCart = message.as(ADD_TO_CART);
+
+      RequestItem requestItem = new RequestItem(addToCart.getQuantity());
+      Message request =
+          MessageBuilder.forAddress(InventoryFn.TYPE, 
Integer.toString(addToCart.getItemId()))
+              .withCustomType(REQUEST_ITEM_TYPE, requestItem)
+              .build();
+      context.send(request);
+    }

Review comment:
       What do you think about using if-else here, or `if (..) { ... return; }` 
?

##########
File path: java/shopping-cart/src/main/statefun-config-sample/module.yaml
##########
@@ -0,0 +1,72 @@
+# 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.
+version: "3.0"
+module:
+  meta:
+    type: remote
+  spec:
+    endpoints:
+      - endpoint:
+          meta:
+            kind: http
+          spec:
+            typename:
+              namespace: example
+              type: greeter
+            urlPathTemplate: 
http://shopping-cart-service.statefun.svc:8080/statefun

Review comment:
       This is a cool k8sy looking url you got there ;-)
   We might have to change that if this example will be `docker-composed`

##########
File path: java/shopping-cart/src/main/statefun-config-sample/module.yaml
##########
@@ -0,0 +1,72 @@
+# 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.
+version: "3.0"
+module:
+  meta:
+    type: remote
+  spec:
+    endpoints:
+      - endpoint:
+          meta:
+            kind: http
+          spec:
+            typename:
+              namespace: example
+              type: greeter
+            urlPathTemplate: 
http://shopping-cart-service.statefun.svc:8080/statefun
+            maxNumBatchRequests: 500
+            timeouts:
+              call: 2min
+    ingresses:
+      - ingress:
+          meta:
+            type: statefun.kafka.io/universal-ingress
+            id: example.com/shopping-cart-updates
+          spec:
+            address: cp-cp-kafka.confluent-platform.svc:9092
+            consumerGroupId: my-group-id
+            topics:
+              - topic: shopping-cart-updates
+                # ? Unclear which type to use if multiple cart-related messages

Review comment:
       🤔 This is a very good question!
   Yes, I think that you are right, we don't have meta types.
   One way to approach this is indeed adding a `kind` field in your JSON 
schema, and to handle this with Jackson.
   The typeUrl that you can write here will be a bit generic, for example 
`com.example/ShoppingCartEvents`.
   And delegate the polymorphic deserialization to Jackson.
   
   Another way, specifically for the cart function is:
   1. ignoring the typeUrl and obtaining the raw bytes 
(`message.getRawValue()`).
   2. using Jackson's readTree 
   3. inspect the real type 
   4. convert the tree to the specific object.
   
   We need to see what is easier to grok in that case.

##########
File path: java/shopping-cart/src/main/statefun-config-sample/module.yaml
##########
@@ -0,0 +1,72 @@
+# 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.
+version: "3.0"
+module:
+  meta:
+    type: remote
+  spec:
+    endpoints:
+      - endpoint:
+          meta:
+            kind: http
+          spec:
+            typename:
+              namespace: example
+              type: greeter
+            urlPathTemplate: 
http://shopping-cart-service.statefun.svc:8080/statefun
+            maxNumBatchRequests: 500
+            timeouts:
+              call: 2min
+    ingresses:
+      - ingress:
+          meta:
+            type: statefun.kafka.io/universal-ingress
+            id: example.com/shopping-cart-updates
+          spec:
+            address: cp-cp-kafka.confluent-platform.svc:9092

Review comment:
       🙈 

##########
File path: java/shopping-cart/src/main/statefun-config-sample/module.yaml
##########
@@ -0,0 +1,72 @@
+# 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.
+version: "3.0"
+module:
+  meta:
+    type: remote
+  spec:
+    endpoints:
+      - endpoint:
+          meta:
+            kind: http
+          spec:
+            typename:
+              namespace: example
+              type: greeter

Review comment:
       I think that you need to remove this line, since you have few functions 
here.
   




----------------------------------------------------------------
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:
[email protected]


Reply via email to