chetanmeh commented on a change in pull request #3886: Proposing Lean OpenWhisk
URL: 
https://github.com/apache/incubator-openwhisk/pull/3886#discussion_r209957227
 
 

 ##########
 File path: common/scala/src/main/scala/whisk/connector/lean/LeanConsumer.scala
 ##########
 @@ -0,0 +1,44 @@
+/*
+ * 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 whisk.connector.lean
+
+import scala.concurrent.duration._
+import whisk.common.Logging
+import whisk.core.connector.MessageConsumer
+import java.util.concurrent.BlockingQueue
+import java.util.concurrent.TimeUnit
+
+class LeanConsumer(queue: BlockingQueue[Array[Byte]], override val maxPeek: 
Int)(implicit logging: Logging)
+    extends MessageConsumer {
+
+  /**
+   */
+  override def peek(duration: FiniteDuration, retry: Int): Iterable[(String, 
Int, Long, Array[Byte])] = {
 
 Review comment:
   @kpavel That helps. I missed on fact that `peek` is designed for long poll. 
In such a case your previous poll based approach would then be better. Looks 
like default java support does not have [drainTo with wait][1]. Guava seems to 
provide [one][2]
   
   [1]: 
https://stackoverflow.com/questions/831834/blockingqueue-blocked-drainto-methods
   [2]: 
https://google.github.io/guava/releases/snapshot-jre/api/docs/com/google/common/collect/Queues.html#drain-java.util.concurrent.BlockingQueue-java.util.Collection-int-long-java.util.concurrent.TimeUnit-

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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

Reply via email to