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/21 03:07:10 UTC

[GitHub] Hellojungle commented on a change in pull request #2: Make code be consistent with Golang Specfication

Hellojungle commented on a change in pull request #2: Make code be consistent with Golang Specfication
URL: https://github.com/apache/rocketmq-client-go/pull/2#discussion_r235241027
 
 

 ##########
 File path: core/api.go
 ##########
 @@ -0,0 +1,102 @@
+/*
+ * 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 rocketmq
+
+import "fmt"
+
+func Version() (version string) {
+	return GetVersion()
+}
+
+// NewProduer create a new producer with config
+func NewProduer(config *ProducerConfig) Producer {
+	return newDefaultProducer(config)
+}
+
+// ProducerConfig define a producer
+type ProducerConfig struct {
+	GroupID		string
+	NameServer  string
+	Credentials *SessionCredentials
+}
+
+func (config *ProducerConfig) String() string {
+	// For security, don't print Credentials default.
+	return fmt.Sprintf("[groupId: %s, nameServer: %s]", config.NameServer, config.GroupID)
+}
+
+type Producer interface {
+	baseAPI
+	// SendMessageSync send a message with sync
+	SendMessageSync(msg *Message) SendResult
+
+	// SendMessageAsync send a message with async
+	SendMessageAsync(msg *Message)
+}
+
+// NewPushConsumer create a new consumer with config.
+func NewPushConsumer(config *ConsumerConfig) (PushConsumer, error) {
+	return newPushConsumer(config)
+}
+
+// ConsumerConfig define a new conusmer.
+type ConsumerConfig struct {
+	GroupID             string
+	NameServer          string
+	ConsumerThreadCount int
+	MessageBatchMaxSize int
+	//ConsumerInstanceName int
+	Credentials *SessionCredentials
+}
+
+func (config *ConsumerConfig) String() string {
+	return fmt.Sprintf("[groupId: %s, nameServer: %s, consumerThreadCount: %d, messageBatchMaxSize: %d]",
+		config.GroupID, config.NameServer, config.ConsumerThreadCount, config.MessageBatchMaxSize)
+}
+
+type PushConsumer interface {
 
 Review comment:
   Is PushConsumer the baseAPI? what about Consumer?

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