You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@eventmesh.apache.org by mi...@apache.org on 2022/10/28 06:33:56 UTC

[incubator-eventmesh] branch master updated: extract go sdk constant

This is an automated email from the ASF dual-hosted git repository.

mikexue pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-eventmesh.git


The following commit(s) were added to refs/heads/master by this push:
     new 8e1dba8b extract go sdk constant
     new 4c0dddba Merge pull request #1984 from horoc/extract-go-sdk-constant
8e1dba8b is described below

commit 8e1dba8b8c706b97098801b8c67b512e81ffa027
Author: horoc <ho...@gmail.com>
AuthorDate: Thu Oct 27 22:54:41 2022 +0800

    extract go sdk constant
---
 eventmesh-sdk-go/http/constant/protocol_type.go    | 24 ++++++++++++++++++++++
 .../http/producer/cloudevent_producer.go           |  6 +++---
 2 files changed, 27 insertions(+), 3 deletions(-)

diff --git a/eventmesh-sdk-go/http/constant/protocol_type.go b/eventmesh-sdk-go/http/constant/protocol_type.go
new file mode 100644
index 00000000..c7b88c7e
--- /dev/null
+++ b/eventmesh-sdk-go/http/constant/protocol_type.go
@@ -0,0 +1,24 @@
+// 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 constant
+
+const (
+	EventMeshMessageProtocol = "eventmeshmessage"
+	CloudEventsProtocol      = "cloudevents"
+	OpenMessageProtocol      = "openmessage"
+)
+
+const ProtocolDesc = "http"
diff --git a/eventmesh-sdk-go/http/producer/cloudevent_producer.go b/eventmesh-sdk-go/http/producer/cloudevent_producer.go
index 35e76c1f..ef9ec0bd 100644
--- a/eventmesh-sdk-go/http/producer/cloudevent_producer.go
+++ b/eventmesh-sdk-go/http/producer/cloudevent_producer.go
@@ -23,6 +23,7 @@ import (
 	gutils "github.com/apache/incubator-eventmesh/eventmesh-sdk-go/common/utils"
 	"github.com/apache/incubator-eventmesh/eventmesh-sdk-go/http"
 	"github.com/apache/incubator-eventmesh/eventmesh-sdk-go/http/conf"
+	"github.com/apache/incubator-eventmesh/eventmesh-sdk-go/http/constant"
 	"github.com/apache/incubator-eventmesh/eventmesh-sdk-go/http/model"
 	"github.com/apache/incubator-eventmesh/eventmesh-sdk-go/http/utils"
 	"github.com/apache/incubator-eventmesh/eventmesh-sdk-go/log"
@@ -76,9 +77,8 @@ func (c *CloudEventProducer) buildCommonPostParam(event cloudevents.Event) *mode
 	requestParam.AddHeader(common.ProtocolKey.ClientInstanceKey.USERNAME, c.EventMeshHttpClientConfig.UserName())
 	requestParam.AddHeader(common.ProtocolKey.ClientInstanceKey.PASSWORD, c.EventMeshHttpClientConfig.Password())
 	requestParam.AddHeader(common.ProtocolKey.LANGUAGE, gcommon.Constants.LANGUAGE_GO)
-	// FIXME Improve constants
-	requestParam.AddHeader(common.ProtocolKey.PROTOCOL_TYPE, "cloudevents")
-	requestParam.AddHeader(common.ProtocolKey.PROTOCOL_DESC, "http")
+	requestParam.AddHeader(common.ProtocolKey.PROTOCOL_TYPE, constant.CloudEventsProtocol)
+	requestParam.AddHeader(common.ProtocolKey.PROTOCOL_DESC, constant.ProtocolDesc)
 	requestParam.AddHeader(common.ProtocolKey.PROTOCOL_VERSION, event.SpecVersion())
 
 	// todo: move producerGroup tp header


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: commits-help@eventmesh.apache.org