You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2018/11/14 04:07:56 UTC

[GitHub] zjykzk commented on a change in pull request #1: Add Producer and PushConsumer

zjykzk commented on a change in pull request #1: Add Producer and PushConsumer
URL: https://github.com/apache/rocketmq-client-go/pull/1#discussion_r233308762
 
 

 ##########
 File path: src/client/pushconsumer.go
 ##########
 @@ -0,0 +1,92 @@
+/*
+ * 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 client
+
+//#cgo CFLAGS: -I/usr/local/include/rocketmq
+//#cgo LDFLAGS: -L/usr/local/lib -lrocketmq
+//#include "CMessageExt.h"
+//#include "CPushConsumer.h"
+//extern int ConsumeMessageCallback(CPushConsumer *consumer,CMessageExt *msg);
+//int ConsumerMessageCallBackInner(CPushConsumer *consumer, CMessageExt *msg) {
+//return ConsumeMessageCallback(consumer,msg);
+//}
+//int SetConsumerMessageCallBackInner(CPushConsumer *consumer) {
+//return RegisterMessageCallback(consumer,ConsumerMessageCallBackInner);
+//}
+import "C"
+import "fmt"
+
+//type PushConsumer C.struct_CPushConsumer
+//type MessageExt C.struct_CMessageExt
+type Callback func(msg MessageExt) ConsumeStatus
+
+func CreatePushConsumer(groupId string) (consumer PushConsumer) {
+	consumer = C.CreatePushConsumer(C.CString(groupId))
+	return consumer;
+}
+func DestroyPushConsumer(consumer PushConsumer) {
+	consumer = C.DestroyPushConsumer(consumer.(*C.struct_CPushConsumer))
+	return
+}
+func StartPushConsumer(consumer PushConsumer) int {
 
 Review comment:
   why not be consistent with the golang style
   
   programing with the c style using golang that maybe not good idea

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


With regards,
Apache Git Services