Skip to content
Snippets Groups Projects
Commit f6b1d6af authored by vito.he's avatar vito.he
Browse files

Add:2.6.0 application config mod

parent ebedbf2b
No related branches found
No related tags found
No related merge requests found
......@@ -38,5 +38,11 @@ const (
)
const (
//EXPORT_KEY = "export"
APPLICATION_KEY = "application"
ORGANIZATION_KEY = "organization"
NAME_KEY = "name"
MODULE_KEY = "module"
APP_VERSION_KEY = "version"
OWNER_KEY = "owner"
ENVIRONMENT_KEY = "environment"
)
......@@ -47,15 +47,10 @@ type RegistryURL struct {
Version string `yaml:"version" json:"version,omitempty"`
Group string `yaml:"group" json:"group,omitempty"`
//for registry
Username string `yaml:"username" json:"username,omitempty"`
Password string `yaml:"password" json:"password,omitempty"`
DubboType DubboType `yaml:"-"`
Organization string `yaml:"organization" json:"organization,omitempty"`
Name string `yaml:"name" json:"name,omitempty"`
Module string `yaml:"module" json:"module,omitempty"`
Owner string `yaml:"owner" json:"owner,omitempty"`
Environment string `yaml:"environment" json:"environment,omitempty"`
Address string `yaml:"address" json:"address,omitempty"`
Username string `yaml:"username" json:"username,omitempty"`
Password string `yaml:"password" json:"password,omitempty"`
DubboType DubboType `yaml:"-"`
Address string `yaml:"address" json:"address,omitempty"`
}
func NewRegistryURL(context context.Context, urlString string) (*RegistryURL, error) {
......
......@@ -142,8 +142,6 @@ type ConsumerConfig struct {
// codec & selector & transport & registry
Selector string `default:"cache" yaml:"selector" json:"selector,omitempty"`
Selector_TTL string `default:"10m" yaml:"selector_ttl" json:"selector_ttl,omitempty"`
//client load balance algorithm
ClientLoadBalance string `default:"round_robin" yaml:"client_load_balance" json:"client_load_balance,omitempty"`
// application
ApplicationConfig ApplicationConfig `yaml:"application_config" json:"application_config,omitempty"`
Registries []RegistryConfig `yaml:"registries" json:"registries,omitempty"`
......@@ -168,10 +166,11 @@ func GetConsumerConfig() ConsumerConfig {
/////////////////////////
type ProviderConfig struct {
Path string `yaml:"path" json:"path,omitempty"`
Registries []RegistryConfig `yaml:"registries" json:"registries,omitempty"`
Services []ServiceConfig `yaml:"services" json:"services,omitempty"`
Protocols []ProtocolConfig `yaml:"protocols" json:"protocols,omitempty"`
ApplicationConfig ApplicationConfig `yaml:"application_config" json:"application_config,omitempty"`
Path string `yaml:"path" json:"path,omitempty"`
Registries []RegistryConfig `yaml:"registries" json:"registries,omitempty"`
Services []ServiceConfig `yaml:"services" json:"services,omitempty"`
Protocols []ProtocolConfig `yaml:"protocols" json:"protocols,omitempty"`
}
func SetProviderConfig(p ProviderConfig) {
......
......@@ -2,16 +2,16 @@ package support
import (
"context"
"github.com/dubbo/dubbo-go/common/constant"
"github.com/dubbo/dubbo-go/config"
"net/url"
"strconv"
"time"
)
import (
"github.com/dubbo/dubbo-go/common/constant"
"github.com/dubbo/dubbo-go/common/extension"
"github.com/dubbo/dubbo-go/common/proxy"
"github.com/dubbo/dubbo-go/config"
"github.com/dubbo/dubbo-go/protocol"
)
......@@ -77,6 +77,15 @@ func (refconfig *ReferenceConfig) getUrlMap() url.Values {
//getty invoke async or sync
urlMap.Set(constant.ASYNC_KEY, strconv.FormatBool(refconfig.Async))
//application info
urlMap.Set(constant.APPLICATION_KEY, consumerConfig.ApplicationConfig.Name)
urlMap.Set(constant.ORGANIZATION_KEY, consumerConfig.ApplicationConfig.Organization)
urlMap.Set(constant.NAME_KEY, consumerConfig.ApplicationConfig.Name)
urlMap.Set(constant.MODULE_KEY, consumerConfig.ApplicationConfig.Module)
urlMap.Set(constant.APP_VERSION_KEY, consumerConfig.ApplicationConfig.Version)
urlMap.Set(constant.OWNER_KEY, consumerConfig.ApplicationConfig.Owner)
urlMap.Set(constant.ENVIRONMENT_KEY, consumerConfig.ApplicationConfig.Environment)
for _, v := range refconfig.Methods {
urlMap.Set("methods."+v.name+"."+constant.LOADBALANCE_KEY, v.loadbalance)
urlMap.Set("methods."+v.name+"."+constant.RETRIES_KEY, strconv.FormatInt(v.retries, 10))
......
......@@ -107,6 +107,15 @@ func (srvconfig *ServiceConfig) getUrlMap() url.Values {
urlMap.Set(constant.WARMUP_KEY, srvconfig.warmup)
urlMap.Set(constant.RETRIES_KEY, strconv.FormatInt(srvconfig.retries, 10))
//application info
urlMap.Set(constant.APPLICATION_KEY, providerConfig.ApplicationConfig.Name)
urlMap.Set(constant.ORGANIZATION_KEY, providerConfig.ApplicationConfig.Organization)
urlMap.Set(constant.NAME_KEY, providerConfig.ApplicationConfig.Name)
urlMap.Set(constant.MODULE_KEY, providerConfig.ApplicationConfig.Module)
urlMap.Set(constant.APP_VERSION_KEY, providerConfig.ApplicationConfig.Version)
urlMap.Set(constant.OWNER_KEY, providerConfig.ApplicationConfig.Owner)
urlMap.Set(constant.ENVIRONMENT_KEY, providerConfig.ApplicationConfig.Environment)
for _, v := range srvconfig.Methods {
urlMap.Set("methods."+v.name+"."+constant.LOADBALANCE_KEY, v.loadbalance)
urlMap.Set("methods."+v.name+"."+constant.RETRIES_KEY, strconv.FormatInt(v.retries, 10))
......
......@@ -6,6 +6,7 @@ import (
"net/url"
"os"
"strconv"
"strings"
"sync"
"time"
)
......@@ -18,6 +19,7 @@ import (
)
import (
"github.com/dubbo/dubbo-go/common/constant"
"github.com/dubbo/dubbo-go/common/extension"
"github.com/dubbo/dubbo-go/config"
"github.com/dubbo/dubbo-go/registry"
......@@ -78,12 +80,12 @@ func NewZkRegistry(url *config.RegistryURL) (registry.Registry, error) {
zkPath: make(map[string]int),
}
if r.Name == "" {
r.Name = RegistryZkClient
}
if r.Version == "" {
r.Version = version.Version
}
//if r.URL.Name == "" {
// r.URL.Name = RegistryZkClient
//}
//if r.Version == "" {
// r.Version = version.Version
//}
if r.Timeout == 0 {
r.Timeout = 1e9
......@@ -283,12 +285,12 @@ func (r *ZkRegistry) register(c config.URL) error {
}
params = url.Values{}
params.Add("application", r.Name)
params.Add("application", c.GetParam(constant.APPLICATION_KEY, ""))
params.Add("default.timeout", fmt.Sprintf("%d", defaultTimeout/1e6))
params.Add("environment", r.Environment)
params.Add("org", r.Organization)
params.Add("module", r.Module)
params.Add("owner", r.Owner)
params.Add("environment", c.GetParam(constant.ENVIRONMENT_KEY, ""))
params.Add("org", c.GetParam(constant.ORGANIZATION_KEY, ""))
params.Add("module", c.GetParam(constant.MODULE_KEY, ""))
params.Add("owner", c.GetParam(constant.OWNER_KEY, ""))
params.Add("pid", processID)
params.Add("ip", localIP)
params.Add("timeout", fmt.Sprintf("%d", int64(r.Timeout)/1e6))
......@@ -309,7 +311,7 @@ func (r *ZkRegistry) register(c config.URL) error {
case config.PROVIDER:
if conf.Service == "" || conf.Methods == "" {
if conf.Service == "" || len(conf.Methods) == 0 {
return jerrors.Errorf("conf{Service:%s, Methods:%s}", conf.Service, conf.Methods)
}
// 先创建服务下面的provider node
......@@ -338,8 +340,8 @@ func (r *ZkRegistry) register(c config.URL) error {
if conf.Version != "" {
params.Add("version", conf.Version)
}
if conf.Methods != "" {
params.Add("methods", conf.Methods)
if len(conf.Methods) == 0 {
params.Add("methods", strings.Join(conf.Methods, ","))
}
log.Debug("provider zk url params:%#v", params)
var path = conf.Path
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment