Skip to content

Commit

Permalink
Merge pull request #673 from apache/refact-seri
Browse files Browse the repository at this point in the history
Rft: network & codec
  • Loading branch information
zouyx committed Sep 22, 2020
1 parent 1d7585f commit 2ceca6f
Show file tree
Hide file tree
Showing 46 changed files with 4,337 additions and 1,600 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ config_center/zookeeper/zookeeper-4unittest/
registry/zookeeper/zookeeper-4unittest/
metadata/report/zookeeper/zookeeper-4unittest/
registry/consul/agent*
metadata/report/consul/agent*
remoting/consul/agent*
config_center/apollo/mockDubbog.properties.json

# vim stuff
Expand Down
1 change: 1 addition & 0 deletions common/constant/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const (
DEFAULT_REST_CLIENT = "resty"
DEFAULT_REST_SERVER = "go-restful"
DEFAULT_PORT = 20000
DEFAULT_SERIALIZATION = HESSIAN2_SERIALIZATION
)

const (
Expand Down
52 changes: 27 additions & 25 deletions common/constant/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,31 +22,32 @@ const (
)

const (
PORT_KEY = "port"
GROUP_KEY = "group"
VERSION_KEY = "version"
INTERFACE_KEY = "interface"
PATH_KEY = "path"
PROTOCOL_KEY = "protocol"
SERVICE_KEY = "service"
METHODS_KEY = "methods"
TIMEOUT_KEY = "timeout"
CATEGORY_KEY = "category"
CHECK_KEY = "check"
ENABLED_KEY = "enabled"
SIDE_KEY = "side"
OVERRIDE_PROVIDERS_KEY = "providerAddresses"
BEAN_NAME_KEY = "bean.name"
GENERIC_KEY = "generic"
CLASSIFIER_KEY = "classifier"
TOKEN_KEY = "token"
LOCAL_ADDR = "local-addr"
REMOTE_ADDR = "remote-addr"
PATH_SEPARATOR = "/"
DUBBO_KEY = "dubbo"
RELEASE_KEY = "release"
ANYHOST_KEY = "anyhost"
SSL_ENABLED_KEY = "ssl-enabled"
GROUP_KEY = "group"
VERSION_KEY = "version"
INTERFACE_KEY = "interface"
PATH_KEY = "path"
SERVICE_KEY = "service"
METHODS_KEY = "methods"
TIMEOUT_KEY = "timeout"
CATEGORY_KEY = "category"
CHECK_KEY = "check"
ENABLED_KEY = "enabled"
SIDE_KEY = "side"
OVERRIDE_PROVIDERS_KEY = "providerAddresses"
BEAN_NAME_KEY = "bean.name"
GENERIC_KEY = "generic"
CLASSIFIER_KEY = "classifier"
TOKEN_KEY = "token"
LOCAL_ADDR = "local-addr"
REMOTE_ADDR = "remote-addr"
DEFAULT_REMOTING_TIMEOUT = 3000
RELEASE_KEY = "release"
ANYHOST_KEY = "anyhost"
PORT_KEY = "port"
PROTOCOL_KEY = "protocol"
PATH_SEPARATOR = "/"
DUBBO_KEY = "dubbo"
SSL_ENABLED_KEY = "ssl-enabled"
)

const (
Expand Down Expand Up @@ -81,6 +82,7 @@ const (
EXECUTE_REJECTED_EXECUTION_HANDLER_KEY = "execute.limit.rejected.handler"
PROVIDER_SHUTDOWN_FILTER = "pshutdown"
CONSUMER_SHUTDOWN_FILTER = "cshutdown"
SERIALIZATION_KEY = "serialization"
PID_KEY = "pid"
SYNC_REPORT_KEY = "sync.report"
RETRY_PERIOD_KEY = "retry.period"
Expand Down
28 changes: 28 additions & 0 deletions common/constant/serializtion.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* 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 (
S_Hessian2 byte = 2
S_Proto byte = 21
)

const (
HESSIAN2_SERIALIZATION = "hessian2"
PROTOBUF_SERIALIZATION = "protobuf"
)
11 changes: 7 additions & 4 deletions common/url.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package common

import (
"bytes"
"encoding/base64"
"fmt"
"math"
Expand Down Expand Up @@ -325,20 +326,22 @@ func (c URL) Key() string {

// ServiceKey gets a unique key of a service.
func (c URL) ServiceKey() string {
intf := c.GetParam(constant.INTERFACE_KEY, strings.TrimPrefix(c.Path, "/"))
return ServiceKey(c.GetParam(constant.INTERFACE_KEY, strings.TrimPrefix(c.Path, "/")),
c.GetParam(constant.GROUP_KEY, ""), c.GetParam(constant.VERSION_KEY, ""))
}

func ServiceKey(intf string, group string, version string) string {
if intf == "" {
return ""
}
var buf strings.Builder
group := c.GetParam(constant.GROUP_KEY, "")
buf := &bytes.Buffer{}
if group != "" {
buf.WriteString(group)
buf.WriteString("/")
}

buf.WriteString(intf)

version := c.GetParam(constant.VERSION_KEY, "")
if version != "" && version != "0.0.0" {
buf.WriteString(":")
buf.WriteString(version)
Expand Down
4 changes: 3 additions & 1 deletion config/service_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ type ServiceConfig struct {
Methods []*MethodConfig `yaml:"methods" json:"methods,omitempty" property:"methods"`
Warmup string `yaml:"warmup" json:"warmup,omitempty" property:"warmup"`
Retries string `yaml:"retries" json:"retries,omitempty" property:"retries"`
Serialization string `yaml:"serialization" json:"serialization" property:"serialization"`
Params map[string]string `yaml:"params" json:"params,omitempty" property:"params"`
Token string `yaml:"token" json:"token,omitempty" property:"token"`
AccessLog string `yaml:"accesslog" json:"accesslog,omitempty" property:"accesslog"`
Expand Down Expand Up @@ -270,7 +271,8 @@ func (c *ServiceConfig) getUrlMap() url.Values {
urlMap.Set(constant.ROLE_KEY, strconv.Itoa(common.PROVIDER))
urlMap.Set(constant.RELEASE_KEY, "dubbo-golang-"+constant.Version)
urlMap.Set(constant.SIDE_KEY, (common.RoleType(common.PROVIDER)).Role())

// todo: move
urlMap.Set(constant.SERIALIZATION_KEY, c.Serialization)
// application info
urlMap.Set(constant.APPLICATION_KEY, providerConfig.ApplicationConfig.Name)
urlMap.Set(constant.ORGANIZATION_KEY, providerConfig.ApplicationConfig.Organization)
Expand Down
6 changes: 3 additions & 3 deletions metadata/service/exporter/configurable/exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ import (
"github.com/apache/dubbo-go/config"
_ "github.com/apache/dubbo-go/filter/filter_impl"
"github.com/apache/dubbo-go/metadata/service/inmemory"
"github.com/apache/dubbo-go/protocol/dubbo"
_ "github.com/apache/dubbo-go/protocol/dubbo"
"github.com/apache/dubbo-go/remoting/getty"
)

func TestConfigurableExporter(t *testing.T) {
dubbo.SetServerConfig(dubbo.ServerConfig{
getty.SetServerConfig(getty.ServerConfig{
SessionNumber: 700,
SessionTimeout: "20s",
GettySessionParam: dubbo.GettySessionParam{
GettySessionParam: getty.GettySessionParam{
CompressEncoding: false,
TcpNoDelay: true,
TcpKeepAlive: true,
Expand Down
Loading

0 comments on commit 2ceca6f

Please sign in to comment.