config

package
v1.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 1, 2020 License: Apache-2.0 Imports: 33 Imported by: 217

Documentation

Overview

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

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

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

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

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

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

Index

Constants

This section is empty.

Variables

Functions

func BeforeShutdown added in v1.3.0

func BeforeShutdown()

func ConsumerInit added in v1.2.0

func ConsumerInit(confConFile string) error

func GetCallback added in v1.3.0

func GetCallback(name string) func(response common.CallbackResponse)

func GetConsumerService

func GetConsumerService(name string) common.RPCService

func GetProviderService

func GetProviderService(name string) common.RPCService

func GetRPCService

func GetRPCService(name string) common.RPCService

get rpc service for consumer

func GracefulShutdownInit added in v1.3.0

func GracefulShutdownInit()

func Load

func Load()

Dubbo Init

func ProviderInit added in v1.2.0

func ProviderInit(confProFile string) error

func RPCService

func RPCService(service common.RPCService)

create rpc service for consumer

func SetConsumerConfig

func SetConsumerConfig(c ConsumerConfig)

func SetConsumerService

func SetConsumerService(service common.RPCService)

SetConService is called by init() of implement of RPCService

func SetProviderConfig

func SetProviderConfig(p ProviderConfig)

func SetProviderService

func SetProviderService(service common.RPCService)

SetProService is called by init() of implement of RPCService

Types

type ApplicationConfig

type ApplicationConfig struct {
	Organization string `yaml:"organization"  json:"organization,omitempty" property:"organization"`
	Name         string `yaml:"name" json:"name,omitempty" property:"name"`
	Module       string `yaml:"module" json:"module,omitempty" property:"module"`
	Version      string `yaml:"version" json:"version,omitempty" property:"version"`
	Owner        string `yaml:"owner" json:"owner,omitempty" property:"owner"`
	Environment  string `yaml:"environment" json:"environment,omitempty" property:"environment"`
}

func (*ApplicationConfig) Id

func (c *ApplicationConfig) Id() string

func (*ApplicationConfig) Prefix

func (*ApplicationConfig) Prefix() string

func (*ApplicationConfig) SetId

func (c *ApplicationConfig) SetId(id string)

func (*ApplicationConfig) UnmarshalYAML added in v1.2.0

func (c *ApplicationConfig) UnmarshalYAML(unmarshal func(interface{}) error) error

type BaseConfig

type BaseConfig struct {
	ConfigCenterConfig *ConfigCenterConfig `yaml:"config_center" json:"config_center,omitempty"`
	// contains filtered or unexported fields
}

func (*BaseConfig) SetFatherConfig

func (c *BaseConfig) SetFatherConfig(fatherConfig interface{})

type ConfigCenterConfig

type ConfigCenterConfig struct {
	Protocol      string `required:"true"  yaml:"protocol"  json:"protocol,omitempty"`
	Address       string `yaml:"address" json:"address,omitempty"`
	Cluster       string `yaml:"cluster" json:"cluster,omitempty"`
	Group         string `default:"dubbo" yaml:"group" json:"group,omitempty"`
	Username      string `yaml:"username" json:"username,omitempty"`
	Password      string `yaml:"password" json:"password,omitempty"`
	ConfigFile    string `default:"dubbo.properties" yaml:"config_file"  json:"config_file,omitempty"`
	Namespace     string `default:"dubbo" yaml:"namespace"  json:"namespace,omitempty"`
	AppConfigFile string `default:"dubbo.properties" yaml:"app_config_file"  json:"app_config_file,omitempty"`
	AppId         string `default:"dubbo" yaml:"app_id"  json:"app_id,omitempty"`
	TimeoutStr    string `yaml:"timeout"  json:"timeout,omitempty"`
	// contains filtered or unexported fields
}

func (*ConfigCenterConfig) GetUrlMap added in v1.3.0

func (c *ConfigCenterConfig) GetUrlMap() url.Values

func (*ConfigCenterConfig) UnmarshalYAML added in v1.2.0

func (c *ConfigCenterConfig) UnmarshalYAML(unmarshal func(interface{}) error) error

type ConsumerConfig

type ConsumerConfig struct {
	BaseConfig `yaml:",inline"`
	Filter     string `yaml:"filter" json:"filter,omitempty" property:"filter"`
	// application
	ApplicationConfig *ApplicationConfig `yaml:"application" json:"application,omitempty" property:"application"`
	// client
	Connect_Timeout string `default:"100ms"  yaml:"connect_timeout" json:"connect_timeout,omitempty" property:"connect_timeout"`
	ConnectTimeout  time.Duration

	Request_Timeout string `yaml:"request_timeout" default:"5s" json:"request_timeout,omitempty" property:"request_timeout"`
	RequestTimeout  time.Duration
	ProxyFactory    string `yaml:"proxy_factory" default:"default" json:"proxy_factory,omitempty" property:"proxy_factory"`
	Check           *bool  `yaml:"check"  json:"check,omitempty" property:"check"`

	Registry       *RegistryConfig             `yaml:"registry" json:"registry,omitempty" property:"registry"`
	Registries     map[string]*RegistryConfig  `yaml:"registries" json:"registries,omitempty" property:"registries"`
	References     map[string]*ReferenceConfig `yaml:"references" json:"references,omitempty" property:"references"`
	ProtocolConf   interface{}                 `yaml:"protocol_conf" json:"protocol_conf,omitempty" property:"protocol_conf"`
	FilterConf     interface{}                 `yaml:"filter_conf" json:"filter_conf,omitempty" property:"filter_conf" `
	ShutdownConfig *ShutdownConfig             `yaml:"shutdown_conf" json:"shutdown_conf,omitempty" property:"shutdown_conf" `
}

func GetConsumerConfig

func GetConsumerConfig() ConsumerConfig

func (*ConsumerConfig) Prefix

func (*ConsumerConfig) Prefix() string

func (*ConsumerConfig) UnmarshalYAML added in v1.2.0

func (c *ConsumerConfig) UnmarshalYAML(unmarshal func(interface{}) error) error

type GenericService added in v1.2.0

type GenericService struct {
	Invoke func(req []interface{}) (interface{}, error) `dubbo:"$invoke"`
	// contains filtered or unexported fields
}

func NewGenericService added in v1.2.0

func NewGenericService(referenceStr string) *GenericService

func (*GenericService) Reference added in v1.2.0

func (u *GenericService) Reference() string

type MethodConfig

type MethodConfig struct {
	InterfaceId                 string
	InterfaceName               string
	Name                        string `yaml:"name"  json:"name,omitempty" property:"name"`
	Retries                     string `yaml:"retries"  json:"retries,omitempty" property:"retries"`
	Loadbalance                 string `yaml:"loadbalance"  json:"loadbalance,omitempty" property:"loadbalance"`
	Weight                      int64  `yaml:"weight"  json:"weight,omitempty" property:"weight"`
	TpsLimitInterval            string `yaml:"tps.limit.interval" json:"tps.limit.interval,omitempty" property:"tps.limit.interval"`
	TpsLimitRate                string `yaml:"tps.limit.rate" json:"tps.limit.rate,omitempty" property:"tps.limit.rate"`
	TpsLimitStrategy            string `yaml:"tps.limit.strategy" json:"tps.limit.strategy,omitempty" property:"tps.limit.strategy"`
	ExecuteLimit                string `yaml:"execute.limit" json:"execute.limit,omitempty" property:"execute.limit"`
	ExecuteLimitRejectedHandler string `` /* 127-byte string literal not displayed */
	Sticky                      bool   `yaml:"sticky"   json:"sticky,omitempty" property:"sticky"`
	RequestTimeout              string `yaml:"timeout"  json:"timeout,omitempty" property:"timeout"`
}

func (*MethodConfig) Prefix

func (c *MethodConfig) Prefix() string

func (*MethodConfig) UnmarshalYAML added in v1.2.0

func (c *MethodConfig) UnmarshalYAML(unmarshal func(interface{}) error) error

type MockService

type MockService struct{}

func (*MockService) GetUser

func (*MockService) GetUser(ctx context.Context, itf []interface{}, str *struct{}) error

func (*MockService) GetUser1

func (*MockService) GetUser1(ctx context.Context, itf []interface{}, str *struct{}) error

func (*MockService) Reference added in v1.2.0

func (*MockService) Reference() string

type ProtocolConfig

type ProtocolConfig struct {
	Name string `required:"true" yaml:"name"  json:"name,omitempty" property:"name"`
	Ip   string `required:"true" yaml:"ip"  json:"ip,omitempty" property:"ip"`
	Port string `required:"true" yaml:"port"  json:"port,omitempty" property:"port"`
}

func (*ProtocolConfig) Prefix

func (c *ProtocolConfig) Prefix() string

type ProviderConfig

type ProviderConfig struct {
	BaseConfig   `yaml:",inline"`
	Filter       string `yaml:"filter" json:"filter,omitempty" property:"filter"`
	ProxyFactory string `yaml:"proxy_factory" default:"default" json:"proxy_factory,omitempty" property:"proxy_factory"`

	ApplicationConfig *ApplicationConfig         `yaml:"application" json:"application,omitempty" property:"application"`
	Registry          *RegistryConfig            `yaml:"registry" json:"registry,omitempty" property:"registry"`
	Registries        map[string]*RegistryConfig `yaml:"registries" json:"registries,omitempty" property:"registries"`
	Services          map[string]*ServiceConfig  `yaml:"services" json:"services,omitempty" property:"services"`
	Protocols         map[string]*ProtocolConfig `yaml:"protocols" json:"protocols,omitempty" property:"protocols"`
	ProtocolConf      interface{}                `yaml:"protocol_conf" json:"protocol_conf,omitempty" property:"protocol_conf" `
	FilterConf        interface{}                `yaml:"filter_conf" json:"filter_conf,omitempty" property:"filter_conf" `
	ShutdownConfig    *ShutdownConfig            `yaml:"shutdown_conf" json:"shutdown_conf,omitempty" property:"shutdown_conf" `
}

func GetProviderConfig

func GetProviderConfig() ProviderConfig

func (*ProviderConfig) Prefix

func (*ProviderConfig) Prefix() string

func (*ProviderConfig) UnmarshalYAML added in v1.2.0

func (c *ProviderConfig) UnmarshalYAML(unmarshal func(interface{}) error) error

type ReferenceConfig

type ReferenceConfig struct {
	InterfaceName string            `required:"true"  yaml:"interface"  json:"interface,omitempty" property:"interface"`
	Check         *bool             `yaml:"check"  json:"check,omitempty" property:"check"`
	Url           string            `yaml:"url"  json:"url,omitempty" property:"url"`
	Filter        string            `yaml:"filter" json:"filter,omitempty" property:"filter"`
	Protocol      string            `default:"dubbo"  yaml:"protocol"  json:"protocol,omitempty" property:"protocol"`
	Registry      string            `yaml:"registry"  json:"registry,omitempty"  property:"registry"`
	Cluster       string            `yaml:"cluster"  json:"cluster,omitempty" property:"cluster"`
	Loadbalance   string            `yaml:"loadbalance"  json:"loadbalance,omitempty" property:"loadbalance"`
	Retries       string            `yaml:"retries"  json:"retries,omitempty" property:"retries"`
	Group         string            `yaml:"group"  json:"group,omitempty" property:"group"`
	Version       string            `yaml:"version"  json:"version,omitempty" property:"version"`
	Methods       []*MethodConfig   `yaml:"methods"  json:"methods,omitempty" property:"methods"`
	Async         bool              `yaml:"async"  json:"async,omitempty" property:"async"`
	Params        map[string]string `yaml:"params"  json:"params,omitempty" property:"params"`

	Generic        bool   `yaml:"generic"  json:"generic,omitempty" property:"generic"`
	Sticky         bool   `yaml:"sticky"   json:"sticky,omitempty" property:"sticky"`
	RequestTimeout string `yaml:"timeout"  json:"timeout,omitempty" property:"timeout"`
	// contains filtered or unexported fields
}

func NewReferenceConfig

func NewReferenceConfig(id string, ctx context.Context) *ReferenceConfig

The only way to get a new ReferenceConfig

func (*ReferenceConfig) GenericLoad added in v1.2.0

func (refconfig *ReferenceConfig) GenericLoad(id string)

func (*ReferenceConfig) GetRPCService

func (refconfig *ReferenceConfig) GetRPCService() common.RPCService

func (*ReferenceConfig) Implement

func (refconfig *ReferenceConfig) Implement(v common.RPCService)

@v is service provider implemented RPCService

func (*ReferenceConfig) Prefix

func (c *ReferenceConfig) Prefix() string

func (*ReferenceConfig) Refer

func (refconfig *ReferenceConfig) Refer(impl interface{})

func (*ReferenceConfig) UnmarshalYAML

func (refconfig *ReferenceConfig) UnmarshalYAML(unmarshal func(interface{}) error) error

type RegistryConfig

type RegistryConfig struct {
	Protocol string `required:"true" yaml:"protocol"  json:"protocol,omitempty" property:"protocol"`
	//I changed "type" to "protocol" ,the same as "protocol" field in java class RegistryConfig
	TimeoutStr string `yaml:"timeout" default:"5s" json:"timeout,omitempty" property:"timeout"` // unit: second
	Group      string `yaml:"group" json:"group,omitempty" property:"group"`
	//for registry
	Address  string            `yaml:"address" json:"address,omitempty" property:"address"`
	Username string            `yaml:"username" json:"username,omitempty" property:"username"`
	Password string            `yaml:"password" json:"password,omitempty"  property:"password"`
	Params   map[string]string `yaml:"params" json:"params,omitempty" property:"params"`
}

func (*RegistryConfig) Prefix

func (*RegistryConfig) Prefix() string

func (*RegistryConfig) UnmarshalYAML added in v1.2.0

func (c *RegistryConfig) UnmarshalYAML(unmarshal func(interface{}) error) error

type ServiceConfig

type ServiceConfig struct {
	Filter                      string            `yaml:"filter" json:"filter,omitempty" property:"filter"`
	Protocol                    string            `default:"dubbo"  required:"true"  yaml:"protocol"  json:"protocol,omitempty" property:"protocol"` // multi protocol support, split by ','
	InterfaceName               string            `required:"true"  yaml:"interface"  json:"interface,omitempty" property:"interface"`
	Registry                    string            `yaml:"registry"  json:"registry,omitempty"  property:"registry"`
	Cluster                     string            `default:"failover" yaml:"cluster"  json:"cluster,omitempty" property:"cluster"`
	Loadbalance                 string            `default:"random" yaml:"loadbalance"  json:"loadbalance,omitempty"  property:"loadbalance"`
	Group                       string            `yaml:"group"  json:"group,omitempty" property:"group"`
	Version                     string            `yaml:"version"  json:"version,omitempty" property:"version" `
	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"`
	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"`
	TpsLimiter                  string            `yaml:"tps.limiter" json:"tps.limiter,omitempty" property:"tps.limiter"`
	TpsLimitInterval            string            `yaml:"tps.limit.interval" json:"tps.limit.interval,omitempty" property:"tps.limit.interval"`
	TpsLimitRate                string            `yaml:"tps.limit.rate" json:"tps.limit.rate,omitempty" property:"tps.limit.rate"`
	TpsLimitStrategy            string            `yaml:"tps.limit.strategy" json:"tps.limit.strategy,omitempty" property:"tps.limit.strategy"`
	TpsLimitRejectedHandler     string            `yaml:"tps.limit.rejected.handler" json:"tps.limit.rejected.handler,omitempty" property:"tps.limit.rejected.handler"`
	ExecuteLimit                string            `yaml:"execute.limit" json:"execute.limit,omitempty" property:"execute.limit"`
	ExecuteLimitRejectedHandler string            `` /* 127-byte string literal not displayed */
	// contains filtered or unexported fields
}

func NewServiceConfig

func NewServiceConfig(id string, context context.Context) *ServiceConfig

The only way to get a new ServiceConfig

func (*ServiceConfig) Export

func (srvconfig *ServiceConfig) Export() error

func (*ServiceConfig) Implement

func (srvconfig *ServiceConfig) Implement(s common.RPCService)

func (*ServiceConfig) Prefix

func (c *ServiceConfig) Prefix() string

func (*ServiceConfig) UnmarshalYAML added in v1.2.0

func (c *ServiceConfig) UnmarshalYAML(unmarshal func(interface{}) error) error

type ShutdownConfig added in v1.3.0

type ShutdownConfig struct {
	/*
	 * Total timeout. Even though we don't release all resources,
	 * the application will shutdown if the costing time is over this configuration. The unit is ms.
	 * default value is 60 * 1000 ms = 1 minutes
	 * In general, it should be bigger than 3 * StepTimeout.
	 */
	Timeout string `default:"60s" yaml:"timeout" json:"timeout,omitempty" property:"timeout"`
	/*
	 * the timeout on each step. You should evaluate the response time of request
	 * and the time that client noticed that server shutdown.
	 * For example, if your client will received the notification within 10s when you start to close server,
	 * and the 99.9% requests will return response in 2s, so the StepTimeout will be bigger than(10+2) * 1000ms,
	 * maybe (10 + 2*3) * 1000ms is a good choice.
	 */
	StepTimeout string `default:"10s" yaml:"step_timeout" json:"step.timeout,omitempty" property:"step.timeout"`
	// when we try to shutdown the application, we will reject the new requests. In most cases, you don't need to configure this.
	RejectRequestHandler string `yaml:"reject_handler" json:"reject_handler,omitempty" property:"reject_handler"`
	// true -> new request will be rejected.
	RejectRequest bool

	// true -> all requests had been processed. In provider side it means that all requests are returned response to clients
	// In consumer side, it means that all requests getting response from servers
	RequestsFinished bool
}

func (*ShutdownConfig) GetStepTimeout added in v1.3.0

func (config *ShutdownConfig) GetStepTimeout() time.Duration

func (*ShutdownConfig) GetTimeout added in v1.3.0

func (config *ShutdownConfig) GetTimeout() time.Duration

func (*ShutdownConfig) Prefix added in v1.3.0

func (config *ShutdownConfig) Prefix() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL