[GitHub] [flink-statefun] sjwiesman commented on a change in pull request #74: [FLINK-16783] Add Python docker-compose based example

2020-03-25 Thread GitBox
sjwiesman commented on a change in pull request #74: [FLINK-16783] Add Python 
docker-compose based example
URL: https://github.com/apache/flink-statefun/pull/74#discussion_r398229803
 
 

 ##
 File path: 
statefun-examples/statefun-python-greeter/generator/event-generator.py
 ##
 @@ -0,0 +1,100 @@
+
+#  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.
+
+
+import signal
+import sys
+import time
+import threading
+
+import random
+
+from kafka.errors import NoBrokersAvailable
+
+from messages_pb2 import GreetRequest, GreetResponse
+
+from kafka import KafkaProducer
+from kafka import KafkaConsumer
+
+KAFKA_BROKER = "kafka-broker:9092"
+NAMES = ["Jerry", "George", "Elaine", "Kramer", "Newman", "Frank"]
+
+
+def random_requests():
+"""Generate infinite sequence of random GreetRequests."""
+while True:
+request = GreetRequest()
+request.name = random.choice(NAMES)
+yield request
+
+
+def produce():
+producer = KafkaProducer(bootstrap_servers=[KAFKA_BROKER])
+for request in random_requests():
+key = request.name.encode('utf-8')
+val = request.SerializeToString()
+producer.send(topic='names', key=key, value=val)
+producer.flush()
+time.sleep(1)
 
 Review comment:
   Could we make this configurable?


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:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [flink-statefun] sjwiesman commented on a change in pull request #74: [FLINK-16783] Add Python docker-compose based example

2020-03-25 Thread GitBox
sjwiesman commented on a change in pull request #74: [FLINK-16783] Add Python 
docker-compose based example
URL: https://github.com/apache/flink-statefun/pull/74#discussion_r398230859
 
 

 ##
 File path: statefun-examples/statefun-python-greeter/greeter/messages.proto
 ##
 @@ -0,0 +1,37 @@
+/*
+ * 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.
+ */
+syntax = "proto3";
+
+// protoc *.proto --python_out=.
+
+package example;
+
+message GreetRequest {
+string name = 1;
+}
+
+message GreetResponse {
+string name = 1;
+string greeting = 2;
+}
+
+message SeenCount {
+int64 seen = 1;
+}
 
 Review comment:
   ```suggestion
   // External request sent by a user who wants to be greeted
   message GreetRequest {
   // The name of the user to greet
   string name = 1;
   }
   
   // A customized response sent to the user
   message GreetResponse {
   // The name of the user being greeted
   string name = 1;
   // The users customized greeting
   string greeting = 2;
   }
   
   // An internal message used to store state
   message SeenCount {
   // The number of times a users has been seen so far
   int64 seen = 1;
   }
   ```


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:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [flink-statefun] sjwiesman commented on a change in pull request #74: [FLINK-16783] Add Python docker-compose based example

2020-03-25 Thread GitBox
sjwiesman commented on a change in pull request #74: [FLINK-16783] Add Python 
docker-compose based example
URL: https://github.com/apache/flink-statefun/pull/74#discussion_r398229803
 
 

 ##
 File path: 
statefun-examples/statefun-python-greeter/generator/event-generator.py
 ##
 @@ -0,0 +1,100 @@
+
+#  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.
+
+
+import signal
+import sys
+import time
+import threading
+
+import random
+
+from kafka.errors import NoBrokersAvailable
+
+from messages_pb2 import GreetRequest, GreetResponse
+
+from kafka import KafkaProducer
+from kafka import KafkaConsumer
+
+KAFKA_BROKER = "kafka-broker:9092"
+NAMES = ["Jerry", "George", "Elaine", "Kramer", "Newman", "Frank"]
+
+
+def random_requests():
+"""Generate infinite sequence of random GreetRequests."""
+while True:
+request = GreetRequest()
+request.name = random.choice(NAMES)
+yield request
+
+
+def produce():
+producer = KafkaProducer(bootstrap_servers=[KAFKA_BROKER])
+for request in random_requests():
+key = request.name.encode('utf-8')
+val = request.SerializeToString()
+producer.send(topic='names', key=key, value=val)
+producer.flush()
+time.sleep(1)
 
 Review comment:
   Could we make this configurable. 


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:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [flink-statefun] sjwiesman commented on a change in pull request #74: [FLINK-16783] Add Python docker-compose based example

2020-03-25 Thread GitBox
sjwiesman commented on a change in pull request #74: [FLINK-16783] Add Python 
docker-compose based example
URL: https://github.com/apache/flink-statefun/pull/74#discussion_r398229298
 
 

 ##
 File path: statefun-examples/statefun-python-greeter/greeter/requirements.txt
 ##
 @@ -0,0 +1,22 @@
+#
+# 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.
+
+apache-flink-statefun
+flask
 
 Review comment:
   Can you please pin the flask version


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:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [flink-statefun] sjwiesman commented on a change in pull request #74: [FLINK-16783] Add Python docker-compose based example

2020-03-25 Thread GitBox
sjwiesman commented on a change in pull request #74: [FLINK-16783] Add Python 
docker-compose based example
URL: https://github.com/apache/flink-statefun/pull/74#discussion_r398229542
 
 

 ##
 File path: 
statefun-examples/statefun-python-greeter/generator/event-generator.py
 ##
 @@ -0,0 +1,100 @@
+
+#  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.
+
+
+import signal
+import sys
+import time
+import threading
+
+import random
+
+from kafka.errors import NoBrokersAvailable
+
+from messages_pb2 import GreetRequest, GreetResponse
+
+from kafka import KafkaProducer
+from kafka import KafkaConsumer
+
+KAFKA_BROKER = "kafka-broker:9092"
+NAMES = ["Jerry", "George", "Elaine", "Kramer", "Newman", "Frank"]
 
 Review comment:
   <3


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:
us...@infra.apache.org


With regards,
Apache Git Services