config

package
v3.0.0-rc1 Latest Latest
Warning

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

Go to latest
Published: May 15, 2021 License: Apache-2.0 Imports: 44 Imported by: 141

Documentation

Index

Constants

View Source
const (
	MaxWheelTimeSpan = 900e9 // 900s, 15 minute
)

Variables

View Source
var (
	// ShutdownSignals receives shutdown signals to process
	ShutdownSignals = []os.Signal{
		os.Interrupt, os.Kill, syscall.SIGKILL, syscall.SIGSTOP,
		syscall.SIGHUP, syscall.SIGINT, syscall.SIGQUIT, syscall.SIGILL, syscall.SIGTRAP,
		syscall.SIGABRT, syscall.SIGSYS, syscall.SIGTERM,
	}

	// DumpHeapShutdownSignals receives shutdown signals to process
	DumpHeapShutdownSignals = []os.Signal{
		syscall.SIGQUIT, syscall.SIGILL,
		syscall.SIGTRAP, syscall.SIGABRT, syscall.SIGSYS,
	}
)

Functions

func BaseInit

func BaseInit(confBaseFile string) error

func BeforeShutdown

func BeforeShutdown()

BeforeShutdown provides processing flow before shutdown

func ConsumerInit

func ConsumerInit(confConFile string) error

ConsumerInit loads config file to init consumer config

func GetAllProviderService

func GetAllProviderService() map[string]common.RPCService

GetAllProviderService gets all ProviderService

func GetCallback

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

GetCallback gets CallbackResponse by @name

func GetClientTlsConfigBuilder

func GetClientTlsConfigBuilder() getty.TlsConfigBuilder

func GetConsumerService

func GetConsumerService(name string) common.RPCService

GetConsumerService gets ConsumerService by @name

func GetProviderService

func GetProviderService(name string) common.RPCService

GetProviderService gets ProviderService by @name

func GetRPCService

func GetRPCService(name string) common.RPCService

GetRPCService get rpc service for consumer

func GetServerTlsConfigBuilder

func GetServerTlsConfigBuilder() getty.TlsConfigBuilder

func GetSslEnabled

func GetSslEnabled() bool

func GracefulShutdownInit

func GracefulShutdownInit()

nolint

func IsProvider

func IsProvider() bool

func Load

func Load()

Load Dubbo Init

func LoadWithOptions

func LoadWithOptions(options ...LoaderInitOption)

func ProviderInit

func ProviderInit(confProFile string) error

ProviderInit loads config file to init provider config

func RPCService

func RPCService(service common.RPCService)

RPCService create rpc service for consumer

func RouterInit

func RouterInit(vsConfigPath, drConfigPath string) error

RouterInit Set config file to init router config

func SetClientTlsConfigBuilder

func SetClientTlsConfigBuilder(configBuilder getty.TlsConfigBuilder)

func SetConsumerConfig

func SetConsumerConfig(c ConsumerConfig)

SetConsumerConfig sets consumerConfig by @c

func SetConsumerService

func SetConsumerService(service common.RPCService)

SetConsumerService is called by init() of implement of RPCService

func SetProviderConfig

func SetProviderConfig(p ProviderConfig)

SetProviderConfig sets provider config by @p

func SetProviderService

func SetProviderService(service common.RPCService)

SetProviderService is called by init() of implement of RPCService

func SetServerTlsConfigBuilder

func SetServerTlsConfigBuilder(configBuilder getty.TlsConfigBuilder)

func SetSslEnabled

func SetSslEnabled(enabled bool)

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"`
	// the metadata type. remote or local
	MetadataType string `default:"local" yaml:"metadataType" json:"metadataType,omitempty" property:"metadataType"`
}

ApplicationConfig is a configuration for current application, whether the application is a provider or a consumer

func GetApplicationConfig

func GetApplicationConfig() *ApplicationConfig

GetApplicationConfig find the application config if not, we will create one Usually applicationConfig will be initialized when system start we use double-check to reduce race condition In general, it will be locked 0 or 1 time. So you don't need to worry about the race condition

func NewApplicationConfig

func NewApplicationConfig(opts ...ApplicationConfigOpt) *ApplicationConfig

NewApplicationConfig is named as api, because there is NewServiceConfig func already declared NewApplicationConfig returns ApplicationConfig wigh default application config

func NewDefaultApplicationConfig

func NewDefaultApplicationConfig() *ApplicationConfig

NewDefaultApplicationConfig returns ApplicationConfig with default name: dubbo.io module: sample organization: dubbo.io owner: dubbogo version: 0.0.1 environment dev

func (*ApplicationConfig) Prefix

func (*ApplicationConfig) Prefix() string

nolint

func (*ApplicationConfig) UnmarshalYAML

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

UnmarshalYAML unmarshals the ApplicationConfig by @unmarshal function

type ApplicationConfigOpt

type ApplicationConfigOpt func(config *ApplicationConfig) *ApplicationConfig

/////////////////////////////////////// Application config api ApplicationConfigOpt is option to init ApplicationConfig

func WithAppEnvironment

func WithAppEnvironment(env string) ApplicationConfigOpt

WithAppEnvironment returns ApplicationConfigOpt wigh given environment @env

func WithAppModule

func WithAppModule(module string) ApplicationConfigOpt

WithAppModule returns ApplicationConfigOpt with given @module

func WithAppName

func WithAppName(name string) ApplicationConfigOpt

WithAppName returns ApplicationConfigOpt with given @name

func WithAppOrganization

func WithAppOrganization(org string) ApplicationConfigOpt

WithAppOrganization returns ApplicationConfigOpt wight given organization @org

func WithAppOwner

func WithAppOwner(owner string) ApplicationConfigOpt

WithAppOwner returns ApplicationConfigOpt with given @owner

func WithAppVersion

func WithAppVersion(version string) ApplicationConfigOpt

WithAppVersion returns ApplicationConfigOpt with given version @version

type BaseConfig

type BaseConfig struct {
	ConfigCenterConfig *ConfigCenterConfig `yaml:"config_center" json:"config_center,omitempty"`

	// since 1.5.0 version
	Remotes              map[string]*RemoteConfig           `yaml:"remote" json:"remote,omitempty"`
	ServiceDiscoveries   map[string]*ServiceDiscoveryConfig `yaml:"service_discovery" json:"service_discovery,omitempty"`
	MetadataReportConfig *MetadataReportConfig              `yaml:"metadata_report" json:"metadata_report,omitempty" property:"metadata_report"`

	// application config
	ApplicationConfig *ApplicationConfig `yaml:"application" json:"application,omitempty" property:"application"`

	EventDispatcherType string        `default:"direct" yaml:"event_dispatcher_type" json:"event_dispatcher_type,omitempty"`
	MetricConfig        *MetricConfig `yaml:"metrics" json:"metrics,omitempty"`

	// cache file used to store the current used configurations.
	CacheFile string `yaml:"cache_file" json:"cache_file,omitempty" property:"cache_file"`
	// contains filtered or unexported fields
}

BaseConfig is the common configuration for provider and consumer

func GetBaseConfig

func GetBaseConfig() *BaseConfig

func (*BaseConfig) GetRemoteConfig

func (c *BaseConfig) GetRemoteConfig(name string) (config *RemoteConfig, ok bool)

GetRemoteConfig will return the remote's config with the name if found

func (*BaseConfig) GetServiceDiscoveries

func (c *BaseConfig) GetServiceDiscoveries(name string) (config *ServiceDiscoveryConfig, ok bool)

nolint

func (*BaseConfig) SetFatherConfig

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

SetFatherConfig sets father config by @fatherConfig

type BoolMatch

type BoolMatch struct {
	Exact bool `yaml:"exact" json:"exact"`
}

nolint

type ConfigCenterConfig

type ConfigCenterConfig struct {
	// context       context.Context
	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"`
	LogDir        string `yaml:"log_dir" json:"log_dir,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"`
	RemoteRef     string `required:"false"  yaml:"remote_ref"  json:"remote_ref,omitempty"`
}

ConfigCenterConfig is configuration for config center

ConfigCenter also introduced concepts of namespace and group to better manage Key-Value pairs by group, those configs are already built-in in many professional third-party configuration centers. In most cases, namespace is used to isolate different tenants, while group is used to divide the key set from one tenant into groups.

ConfigCenter has currently supported Zookeeper, Nacos, Etcd, Consul, Apollo

func (*ConfigCenterConfig) GetUrlMap

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

GetUrlMap gets url map from ConfigCenterConfig

func (*ConfigCenterConfig) UnmarshalYAML

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

UnmarshalYAML unmarshals the ConfigCenterConfig by @unmarshal function

type ConsumerConfig

type ConsumerConfig struct {
	BaseConfig `yaml:",inline"`

	Filter string `yaml:"filter" json:"filter,omitempty" property:"filter"`
	// client
	Connect_Timeout string `default:"100ms"  yaml:"connect_timeout" json:"connect_timeout,omitempty" property:"connect_timeout"`
	ConnectTimeout  time.Duration

	Registry   *RegistryConfig            `yaml:"registry" json:"registry,omitempty" property:"registry"`
	Registries map[string]*RegistryConfig `default:"{}" yaml:"registries" json:"registries" property:"registries"`

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

	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"`
	ConfigType     map[string]string           `yaml:"config_type" json:"config_type,omitempty" property:"config_type"`
	// contains filtered or unexported fields
}

ConsumerConfig is Consumer default configuration

func GetConsumerConfig

func GetConsumerConfig() ConsumerConfig

GetConsumerConfig find the consumer config if not found, create new one we use double-check to reduce race condition In general, it will be locked 0 or 1 time. So you don't need to worry about the race condition

func NewConsumerConfig

func NewConsumerConfig(opts ...ConsumerConfigOpt) *ConsumerConfig

NewConsumerConfig returns ConsumerConfig with @opts

func NewDefaultConsumerConfig

func NewDefaultConsumerConfig() *ConsumerConfig

NewDefaultConsumerConfig returns default ConsumerConfig with connection timeout = 3s, request timeout = 3s

func (*ConsumerConfig) Prefix

func (*ConsumerConfig) Prefix() string

nolint

func (*ConsumerConfig) UnmarshalYAML

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

UnmarshalYAML unmarshals the ConsumerConfig by @unmarshal function

type ConsumerConfigOpt

type ConsumerConfigOpt func(config *ConsumerConfig) *ConsumerConfig

/////////////////////////////////// consumer config api ConsumerConfigOpt is the options to init ConsumerConfig

func WithConsumerAppConfig

func WithConsumerAppConfig(appConfig *ApplicationConfig) ConsumerConfigOpt

WithConsumerAppConfig returns ConsumerConfigOpt with given @appConfig

func WithConsumerConfigCenterConfig

func WithConsumerConfigCenterConfig(configCenterConfig *ConfigCenterConfig) ConsumerConfigOpt

WithConsumerConfigCenterConfig returns ConsumerConfigOpt with given @configCenterConfig

func WithConsumerConfigCheck

func WithConsumerConfigCheck(check bool) ConsumerConfigOpt

WithConsumerConfigCheck returns ConsumerConfigOpt with given @check flag

func WithConsumerConnTimeout

func WithConsumerConnTimeout(timeout time.Duration) ConsumerConfigOpt

WithConsumerConnTimeout returns ConsumerConfigOpt with given consumer conn @timeout

func WithConsumerReferenceConfig

func WithConsumerReferenceConfig(referenceKey string, refConfig *ReferenceConfig) ConsumerConfigOpt

WithConsumerReferenceConfig returns ConsumerConfigOpt with

func WithConsumerRegistryConfig

func WithConsumerRegistryConfig(registryKey string, regConfig *RegistryConfig) ConsumerConfigOpt

WithConsumerRegistryConfig returns ConsumerConfigOpt with given @registryKey and @regConfig

func WithConsumerRequestTimeout

func WithConsumerRequestTimeout(timeout time.Duration) ConsumerConfigOpt

WithConsumerRequestTimeout returns ConsumerConfigOpt with given consumer request @timeout

type DestinationRuleConfig

type DestinationRuleConfig struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
	YamlAPIVersion    string              `yaml:"apiVersion" `
	YamlKind          string              `yaml:"kind" `
	MetaData          MetaDataStruct      `yaml:"metadata"`
	Spec              DestinationRuleSpec `yaml:"spec" json:"spec"`
}

DestinationRule Definition

func (*DestinationRuleConfig) DeepCopyObject

func (drc *DestinationRuleConfig) DeepCopyObject() runtime.Object

nolint

type DestinationRuleConfigList

type DestinationRuleConfigList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []DestinationRuleConfig `json:"items"`
}

nolint

func (*DestinationRuleConfigList) DeepCopyObject

func (drc *DestinationRuleConfigList) DeepCopyObject() runtime.Object

nolint

type DestinationRuleSpec

type DestinationRuleSpec struct {
	Host    string                  `yaml:"host" json:"host"`
	SubSets []DestinationRuleSubSet `yaml:"subsets" json:"subsets"`
}

nolint

type DestinationRuleSpecList

type DestinationRuleSpecList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []DestinationRuleSpec `json:"items"`
}

nolint

type DestinationRuleSubSet

type DestinationRuleSubSet struct {
	Name   string            `yaml:"name" json:"name"`
	Labels map[string]string `yaml:"labels" json:"labels"`
}

nolint

type DoubleMatch

type DoubleMatch struct {
	Exact float64           `yaml:"exact" json:"exact"`
	Range *DoubleRangeMatch `yaml:"range" json:"range"`
	Mode  float64           `yaml:"mode" json:"mode"`
}

nolint

type DoubleRangeMatch

type DoubleRangeMatch struct {
	Start float64 `yaml:"start" json:"start"`
	End   float64 `yaml:"end" json:"end"`
}

nolint

type DubboAttachmentMatch

type DubboAttachmentMatch struct {
	EagleeyeContext map[string]*StringMatch `yaml:"eagleeyecontext" json:"eagleeyecontext"`
	DubboContext    map[string]*StringMatch `yaml:"dubbocontext" json:"dubbocontext"`
}

nolint

type DubboDestination

type DubboDestination struct {
	Destination RouterDest `yaml:"destination" json:"destination"`
}

nolint

type DubboMatchRequest

type DubboMatchRequest struct {
	Name         string                  `yaml:"name" json:"name"`
	Method       *DubboMethodMatch       `yaml:"method" json:"method"`
	SourceLabels map[string]string       `yaml:"sourceLabels" json:"sourceLabels"`
	Attachment   *DubboAttachmentMatch   `yaml:"attachments" json:"attachments"`
	Header       map[string]*StringMatch `yaml:"headers" json:"headers"`
	Threshold    *DoubleMatch            `yaml:"threshold" json:"threshold"`
}

nolint

type DubboMethodArg

type DubboMethodArg struct {
	Index     uint32           `yaml:"index" json:"index"`
	Type      string           `yaml:"type" json:"type"`
	StrValue  *ListStringMatch `yaml:"str_value" json:"str_value"`
	NumValue  *ListDoubleMatch `yaml:"num_value" json:"num_value"`
	BoolValue *BoolMatch       `yaml:"bool_value" json:"bool_value"`
}

nolint

type DubboMethodMatch

type DubboMethodMatch struct {
	NameMatch *StringMatch            `yaml:"name_match" json:"name_match"`
	Argc      int                     `yaml:"argc" json:"argc"`
	Args      []*DubboMethodArg       `yaml:"args" json:"args"`
	Argp      []*StringMatch          `yaml:"argp" json:"argp"`
	Headers   map[string]*StringMatch `yaml:"headers" json:"headers"`
}

nolint

type DubboRoute

type DubboRoute struct {
	Services     []*StringMatch            `yaml:"services" json:"service"`
	RouterDetail []*DubboServiceRouterItem `yaml:"routedetail" json:"routedetail"`
}

nolint

type DubboServiceRouterItem

type DubboServiceRouterItem struct {
	Name   string               `yaml:"name" json:"name"`
	Match  []*DubboMatchRequest `yaml:"match" json:"match"`
	Router []*DubboDestination  `yaml:"route" json:"route"`
}

nolint

type GenericService

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

GenericService uses for generic invoke for service call

func NewGenericService

func NewGenericService(referenceStr string) *GenericService

NewGenericService returns a GenericService instance

func (*GenericService) Reference

func (u *GenericService) Reference() string

Reference gets referenceStr from GenericService

type ListDoubleMatch

type ListDoubleMatch struct {
	Oneof []*DoubleMatch `yaml:"oneof" json:"oneof"`
}

nolint

type ListStringMatch

type ListStringMatch struct {
	Oneof []*StringMatch `yaml:"oneof" json:"oneof"`
}

nolint

type LoaderInitOption

type LoaderInitOption interface {
	// contains filtered or unexported methods
}

func BaseInitOption

func BaseInitOption(cbf string) LoaderInitOption

func ConsumerInitOption

func ConsumerInitOption(confConFile string) LoaderInitOption

func ConsumerMustInitOption

func ConsumerMustInitOption(confConFile string) LoaderInitOption

func DefaultInit

func DefaultInit() []LoaderInitOption

loaded consumer & provider config from xxx.yml, and log config from xxx.xml Namely: dubbo.consumer.xml & dubbo.provider.xml in java dubbo

func ProviderInitOption

func ProviderInitOption(confProFile string) LoaderInitOption

func ProviderMustInitOption

func ProviderMustInitOption(confProFile string) LoaderInitOption

func RouterInitOption

func RouterInitOption(crf string) LoaderInitOption

type LocalRouterRules

type LocalRouterRules struct {
	RouterRules []interface{} `yaml:"routerRules"`
}

LocalRouterRules defines the local router config structure

type MetaDataStruct

type MetaDataStruct struct {
	Name string `yaml:"name"`
}

nolint

type MetadataReportConfig

type MetadataReportConfig struct {
	Protocol  string            `required:"true"  yaml:"protocol"  json:"protocol,omitempty"`
	RemoteRef string            `required:"true"  yaml:"remote_ref"  json:"remote_ref,omitempty"`
	Params    map[string]string `yaml:"params" json:"params,omitempty" property:"params"`
	Group     string            `yaml:"group" json:"group,omitempty" property:"group"`
}

MethodConfig is method level configuration

func (*MetadataReportConfig) IsValid

func (c *MetadataReportConfig) IsValid() bool

func (*MetadataReportConfig) Prefix

func (c *MetadataReportConfig) Prefix() string

nolint

func (*MetadataReportConfig) ToUrl

func (c *MetadataReportConfig) ToUrl() (*common.URL, error)

nolint

func (*MetadataReportConfig) UnmarshalYAML

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

UnmarshalYAML unmarshal the MetadataReportConfig by @unmarshal function

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"`
}

MethodConfig defines method config

func (*MethodConfig) Prefix

func (c *MethodConfig) Prefix() string

nolint

func (*MethodConfig) UnmarshalYAML

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

UnmarshalYAML unmarshals the MethodConfig by @unmarshal function

type MetricConfig

type MetricConfig struct {
	Reporters       []string  `yaml:"reporters" json:"reporters,omitempty"`
	HistogramBucket []float64 `yaml:"histogram_bucket" json:"histogram_bucket,omitempty"`
}

This is the config struct for all metrics implementation

func GetMetricConfig

func GetMetricConfig() *MetricConfig

GetMetricConfig find the MetricConfig if it is nil, create a new one we use double-check to reduce race condition In general, it will be locked 0 or 1 time. So you don't need to worry about the race condition

func (*MetricConfig) GetHistogramBucket

func (mc *MetricConfig) GetHistogramBucket() []float64

find the histogram bucket if it's empty, the default value will be return

type MockService

type MockService struct{}

MockService mocks the rpc service for test

func (*MockService) GetUser

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

GetUser mocks the GetUser method

func (*MockService) GetUser1

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

GetUser1 mocks the GetUser1 method

func (*MockService) Reference

func (*MockService) Reference() string

Reference mocks the Reference method

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"`
}

ProtocolConfig is protocol configuration

func (*ProtocolConfig) Prefix

func (c *ProtocolConfig) Prefix() string

nolint

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"`
	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"`
	ConfigType     map[string]string          `yaml:"config_type" json:"config_type,omitempty" property:"config_type"`

	Registry   *RegistryConfig            `yaml:"registry" json:"registry,omitempty" property:"registry"`
	Registries map[string]*RegistryConfig `default:"{}" yaml:"registries" json:"registries" property:"registries"`
	// contains filtered or unexported fields
}

ProviderConfig is the default configuration of service provider

func GetProviderConfig

func GetProviderConfig() ProviderConfig

GetProviderConfig find the provider config if not found, create new one

func NewDefaultProviderConfig

func NewDefaultProviderConfig() *ProviderConfig

NewDefaultProviderConfig returns ProviderConfig with default ApplicationConfig

func NewProviderConfig

func NewProviderConfig(opts ...ProviderConfigOpt) *ProviderConfig

NewProviderConfig returns ProviderConfig with given @opts

func (*ProviderConfig) Prefix

func (*ProviderConfig) Prefix() string

nolint

func (*ProviderConfig) UnmarshalYAML

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

UnmarshalYAML unmarshals the ProviderConfig by @unmarshal function

type ProviderConfigOpt

type ProviderConfigOpt func(config *ProviderConfig) *ProviderConfig

/////////////////////////////////// provider config api ProviderConfigOpt is the

func WithPrividerRegistryConfig

func WithPrividerRegistryConfig(regConfig *RegistryConfig) ProviderConfigOpt

WithPrividerRegistryConfig returns ProviderConfigOpt with given registry config: @regConfig

func WithProviderAppConfig

func WithProviderAppConfig(appConfig *ApplicationConfig) ProviderConfigOpt

WithProviderAppConfig returns ProviderConfigOpt with given @appConfig

func WithProviderProtocol

func WithProviderProtocol(protocolKey, protocol, port string) ProviderConfigOpt

WithProviderProtocol returns ProviderConfigOpt with given @protocolKey, protocolName @protocol and @port

func WithProviderRegistry

func WithProviderRegistry(registryKey string, registryConfig *RegistryConfig) ProviderConfigOpt

WithProviderRegistry returns ProviderConfigOpt with given @registryKey and registry @registryConfig

func WithProviderServices

func WithProviderServices(serviceName string, serviceConfig *ServiceConfig) ProviderConfigOpt

WithProviderServices returns ProviderConfig with given serviceNameKey @serviceName and @serviceConfig

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"`
	Serialization string            `yaml:"serialization" json:"serialization" property:"serialization"`
	ProvideBy     string            `yaml:"provide_by"  json:"provide_by,omitempty" property:"provide_by"`
	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"`
	ForceTag       bool   `yaml:"force.tag"  json:"force.tag,omitempty" property:"force.tag"`
	// contains filtered or unexported fields
}

ReferenceConfig is the configuration of service consumer

func NewDefaultReferenceConfig

func NewDefaultReferenceConfig() *ReferenceConfig

NewDefaultReferenceConfig returns empty ReferenceConfig

func NewReferenceConfig

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

NewReferenceConfig The only way to get a new ReferenceConfig

func NewReferenceConfigByAPI

func NewReferenceConfigByAPI(opts ...ReferenceConfigOpt) *ReferenceConfig

NewReferenceConfigByAPI returns ReferenceConfig with given @opts

func (*ReferenceConfig) GenericLoad

func (c *ReferenceConfig) GenericLoad(id string)

GenericLoad ...

func (*ReferenceConfig) GetInvoker

func (c *ReferenceConfig) GetInvoker() protocol.Invoker

GetInvoker get invoker from ReferenceConfig

func (*ReferenceConfig) GetProxy

func (c *ReferenceConfig) GetProxy() *proxy.Proxy

GetProxy gets proxy

func (*ReferenceConfig) GetRPCService

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

GetRPCService gets RPCService from proxy

func (*ReferenceConfig) Implement

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

Implement @v is service provider implemented RPCService

func (*ReferenceConfig) Prefix

func (c *ReferenceConfig) Prefix() string

nolint

func (*ReferenceConfig) Refer

func (c *ReferenceConfig) Refer(_ interface{})

Refer ...

func (*ReferenceConfig) UnmarshalYAML

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

UnmarshalYAML unmarshals the ReferenceConfig by @unmarshal function

type ReferenceConfigOpt

type ReferenceConfigOpt func(config *ReferenceConfig) *ReferenceConfig

////////////////////////////////// reference config api ReferenceConfigOpt is consumer's reference config

func WithReferenceCluster

func WithReferenceCluster(cluster string) ReferenceConfigOpt

WithReferenceCluster returns ReferenceConfigOpt with given cluster name: @cluster

func WithReferenceInterface

func WithReferenceInterface(interfaceName string) ReferenceConfigOpt

WithReferenceInterface returns ReferenceConfigOpt with given @interfaceName

func WithReferenceMethod

func WithReferenceMethod(methodName, retries, lb string) ReferenceConfigOpt

WithReferenceMethod returns ReferenceConfigOpt with given @method, @retries, and load balance: @lb

func WithReferenceProtocol

func WithReferenceProtocol(protocol string) ReferenceConfigOpt

WithReferenceProtocol returns ReferenceConfigOpt with given protocolKey: @protocol

func WithReferenceRegistry

func WithReferenceRegistry(registry string) ReferenceConfigOpt

WithReferenceRegistry returns ReferenceConfigOpt with given registryKey: @registry

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"`
	TTL        string `yaml:"ttl" default:"10m" json:"ttl,omitempty" property:"ttl"` // unit: minute
	// 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"`
	Simplified bool   `yaml:"simplified" json:"simplified,omitempty"  property:"simplified"`
	// Always use this registry first if set to true, useful when subscribe to multiple registries
	Preferred bool `yaml:"preferred" json:"preferred,omitempty" property:"preferred"`
	// The region where the registry belongs, usually used to isolate traffics
	Zone string `yaml:"zone" json:"zone,omitempty" property:"zone"`
	//// Force must user the region, property zone is specified.
	//ZoneForce bool `yaml:"zoneForce" json:"zoneForce,omitempty" property:"zoneForce"`
	// Affects traffic distribution among registries,
	// useful when subscribe to multiple registries Take effect only when no preferred registry is specified.
	Weight int64             `yaml:"weight" json:"weight,omitempty" property:"weight"`
	Params map[string]string `yaml:"params" json:"params,omitempty" property:"params"`
}

RegistryConfig is the configuration of the registry center

func NewDefaultRegistryConfig

func NewDefaultRegistryConfig(protocol string) *RegistryConfig

NewDefaultRegistryConfig New default registry config the input @protocol can only be: "zookeeper" with default addr "127.0.0.1:2181" "consul" with default addr "127.0.0.1:8500" "nacos" with default addr "127.0.0.1:8848"

func NewRegistryConfig

func NewRegistryConfig(opts ...RegistryConfigOpt) *RegistryConfig

NewRegistryConfig creates New RegistryConfig with @opts

func (*RegistryConfig) Prefix

func (*RegistryConfig) Prefix() string

nolint

func (*RegistryConfig) UnmarshalYAML

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

UnmarshalYAML unmarshals the RegistryConfig by @unmarshal function

type RegistryConfigOpt

type RegistryConfigOpt func(config *RegistryConfig) *RegistryConfig

/////////////////////////////////// registry config api

func WithRegistryAddress

func WithRegistryAddress(addr string) RegistryConfigOpt

WithRegistryAddress returns RegistryConfigOpt with given @addr registry address

func WithRegistryGroup

func WithRegistryGroup(group string) RegistryConfigOpt

WithRegistryGroup returns RegistryConfigOpt with given @group registry group

func WithRegistryParams

func WithRegistryParams(params map[string]string) RegistryConfigOpt

WithRegistryParams returns RegistryConfigOpt with given registry @params

func WithRegistryPassword

func WithRegistryPassword(psw string) RegistryConfigOpt

WithRegistryPassword returns RegistryConfigOpt with given @psw registry password

func WithRegistryPreferred

func WithRegistryPreferred(preferred bool) RegistryConfigOpt

WithRegistryPreferred returns RegistryConfig with given @preferred registry preferred flag

func WithRegistryProtocol

func WithRegistryProtocol(regProtocol string) RegistryConfigOpt

WithRegistryProtocol returns RegistryConfigOpt with given @regProtocol name

func WithRegistrySimplified

func WithRegistrySimplified(simplified bool) RegistryConfigOpt

WithRegistrySimplified returns RegistryConfigOpt with given @simplified registry simplified flag

func WithRegistryTTL

func WithRegistryTTL(ttl string) RegistryConfigOpt

WithRegistryTTL returns RegistryConfigOpt with given @ttl registry ttl

func WithRegistryTimeOut

func WithRegistryTimeOut(timeout string) RegistryConfigOpt

WithRegistryTimeOut returns RegistryConfigOpt with given @timeout registry config

func WithRegistryUserName

func WithRegistryUserName(userName string) RegistryConfigOpt

WithRegistryUserName returns RegistryConfigOpt with given @userName registry userName

func WithRegistryWeight

func WithRegistryWeight(weight int64) RegistryConfigOpt

WithRegistryWeight returns RegistryConfigOpt with given @weight registry weight flag

type RemoteConfig

type RemoteConfig struct {
	Protocol   string            `yaml:"protocol"  json:"protocol,omitempty"`
	Address    string            `yaml:"address" json:"address,omitempty"`
	TimeoutStr string            `default:"5s" yaml:"timeout" json:"timeout,omitempty"`
	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"`
}

RemoteConfig: usually we need some middleware, including nacos, zookeeper this represents an instance of this middleware so that other module, like config center, registry could reuse the config but now, only metadata report, metadata service, service discovery use this structure

func (*RemoteConfig) GetParam

func (rc *RemoteConfig) GetParam(key string, def string) string

GetParam will return the value of the key. If not found, def will be return; def => default value

func (*RemoteConfig) Timeout

func (rc *RemoteConfig) Timeout() time.Duration

Timeout return timeout duration. if the configure is invalid, or missing, the default value 5s will be returned

type RouterDest

type RouterDest struct {
	Host     string            `yaml:"host" json:"host"`
	Subset   string            `yaml:"subset" json:"subset"`
	Weight   int               `yaml:"weight" json:"weight"`
	Fallback *DubboDestination `yaml:"fallback" json:"fallback"`
}

nolint

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"`
	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"`
	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 */
	Auth                        string            `yaml:"auth" json:"auth,omitempty" property:"auth"`
	ParamSign                   string            `yaml:"param.sign" json:"param.sign,omitempty" property:"param.sign"`
	Tag                         string            `yaml:"tag" json:"tag,omitempty" property:"tag"`
	GrpcMaxMessageSize          int               `default:"4" yaml:"max_message_size" json:"max_message_size,omitempty"`

	Protocols map[string]*ProtocolConfig
	// contains filtered or unexported fields
}

ServiceConfig is the configuration of the service provider

func NewDefaultServiceConfig

func NewDefaultServiceConfig() *ServiceConfig

NewDefaultServiceConfig returns default ServiceConfig

func NewServiceConfig

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

NewServiceConfig The only way to get a new ServiceConfig

func NewServiceConfigByAPI

func NewServiceConfigByAPI(opts ...ServiceConfigOpt) *ServiceConfig

NewServiceConfigByAPI is named as api, because there is NewServiceConfig func already declared NewServiceConfigByAPI returns ServiceConfig with given @opts

func (*ServiceConfig) Export

func (c *ServiceConfig) Export() error

Export exports the service

func (*ServiceConfig) GetExportedUrls

func (c *ServiceConfig) GetExportedUrls() []*common.URL

GetExportedUrls will return the url in service config's exporter

func (*ServiceConfig) Implement

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

Implement only store the @s and return

func (*ServiceConfig) InitExported

func (c *ServiceConfig) InitExported()

InitExported will set exported as false atom bool

func (*ServiceConfig) IsExport

func (c *ServiceConfig) IsExport() bool

IsExport will return whether the service config is exported or not

func (*ServiceConfig) Prefix

func (c *ServiceConfig) Prefix() string

Prefix returns dubbo.service.${interface}.

func (*ServiceConfig) Unexport

func (c *ServiceConfig) Unexport()

Unexport will call unexport of all exporters service config exported

func (*ServiceConfig) UnmarshalYAML

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

UnmarshalYAML unmarshals the ServiceConfig by @unmarshal function

type ServiceConfigOpt

type ServiceConfigOpt func(config *ServiceConfig) *ServiceConfig

///////////////////////////////////// service config api ServiceConfigOpt is the option to init ServiceConfig

func WithServiceCluster

func WithServiceCluster(cluster string) ServiceConfigOpt

WithServiceCluster returns ServiceConfigOpt with given cluster name @cluster

func WithServiceInterface

func WithServiceInterface(interfaceName string) ServiceConfigOpt

WithServiceInterface returns ServiceConfigOpt with given @interfaceName

func WithServiceLoadBalance

func WithServiceLoadBalance(lb string) ServiceConfigOpt

WithServiceLoadBalance returns ServiceConfigOpt with given load balance @lb

func WithServiceMethod

func WithServiceMethod(name, retries, lb string) ServiceConfigOpt

WithServiceMethod returns ServiceConfigOpt with given @name, @retries and load balance @lb

func WithServiceProtocol

func WithServiceProtocol(protocol string) ServiceConfigOpt

WithServiceProtocol returns ServiceConfigOpt with given protocolKey @protocol

func WithServiceRegistry

func WithServiceRegistry(registry string) ServiceConfigOpt

WithServiceRegistry returns ServiceConfigOpt with given registryKey @registry

func WithServiceWarmUpTime

func WithServiceWarmUpTime(warmUp string) ServiceConfigOpt

WithServiceWarmUpTime returns ServiceConfigOpt with given @warmUp time

type ServiceDiscoveryConfig

type ServiceDiscoveryConfig struct {
	// Protocol indicate which implementation will be used.
	// for example, if the Protocol is nacos, it means that we will use nacosServiceDiscovery
	Protocol string `yaml:"protocol" json:"protocol,omitempty"`
	// Group, usually you don't need to config this field.
	// you can use this to do some isolation
	Group string `yaml:"group" json:"group,omitempty"`
	// RemoteRef is the reference point to RemoteConfig which will be used to create remotes instances.
	RemoteRef string `yaml:"remote_ref" json:"remote_ref,omitempty"`
}

ServiceDiscoveryConfig will be used to create

type ShutdownConfig

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
}

ShutdownConfig is used as configuration for graceful shutdown

func (*ShutdownConfig) GetStepTimeout

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

nolint

func (*ShutdownConfig) GetTimeout

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

nolint

func (*ShutdownConfig) Prefix

func (config *ShutdownConfig) Prefix() string

nolint

type StringMatch

type StringMatch struct {
	Exact   string `yaml:"exact" json:"exact"`
	Prefix  string `yaml:"prefix" json:"prefix"`
	Regex   string `yaml:"regex" json:"regex"`
	NoEmpty string `yaml:"noempty" json:"noempty"`
	Empty   string `yaml:"empty" json:"empty"`
}

nolint

type UniformRouterConfigSpec

type UniformRouterConfigSpec struct {
	Hosts []string      `yaml:"hosts" json:"hosts"`
	Dubbo []*DubboRoute `yaml:"dubbo" json:"dubbo"`
}

nolint

type VirtualServiceConfig

type VirtualServiceConfig struct {
	YamlAPIVersion    string `yaml:"apiVersion"`
	YamlKind          string `yaml:"kind"`
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
	MetaData          MetaDataStruct          `yaml:"metadata"`
	Spec              UniformRouterConfigSpec `yaml:"spec" json:"spec"`
}

VirtualService Config Definition

func (*VirtualServiceConfig) DeepCopyObject

func (urc *VirtualServiceConfig) DeepCopyObject() runtime.Object

nolint

type VirtualServiceConfigList

type VirtualServiceConfigList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []VirtualServiceConfig `json:"items"`
}

nolint

func (*VirtualServiceConfigList) DeepCopyObject

func (drc *VirtualServiceConfigList) DeepCopyObject() runtime.Object

nolint

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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