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

 ##########
 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:
   there may be no one write golang code with C style. we should definitely 
keep C API clean and simple, but we should provide friendly API for users in 
go, too. Actually, we can wrap C API in go in order to expose Golang-Style API, 
 i had cloned code from @ShannonDing codebase and refactored it as soon as 
possible. the codebase will be consistent with the golang style after 
refactoring.

----------------------------------------------------------------
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