config

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 29, 2019 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetConsumerService

func GetConsumerService(name string) common.RPCService

func GetProviderService

func GetProviderService(name string) common.RPCService

func Load

func Load() (map[string]*ReferenceConfig, map[string]*ServiceConfig)

Dubbo Init

func SetConsumerConfig

func SetConsumerConfig(c ConsumerConfig)

func SetConsumerService

func SetConsumerService(service common.RPCService)

SetConService is called by init() of implement of RPCService

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"`
	Name         string `yaml:"name" json:"name,omitempty"`
	Module       string `yaml:"module" json:"module,omitempty"`
	Version      string `yaml:"version" json:"version,omitempty"`
	Owner        string `yaml:"owner" json:"owner,omitempty"`
	Environment  string `yaml:"environment" json:"environment,omitempty"`
}

type ConfigRegistry

type ConfigRegistry string

type ConsumerConfig

type ConsumerConfig struct {
	Filter string `yaml:"filter" json:"filter,omitempty"`

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

	Request_Timeout string `yaml:"request_timeout" default:"5s" json:"request_timeout,omitempty"`
	RequestTimeout  time.Duration
	ProxyFactory    string `yaml:"proxy_factory" default:"default" json:"proxy_factory,omitempty"`
	Check           *bool  `yaml:"check"  json:"check,omitempty"`
	// application
	ApplicationConfig ApplicationConfig `yaml:"application_config" json:"application_config,omitempty"`
	Registries        []RegistryConfig  `yaml:"registries" json:"registries,omitempty"`
	References        []ReferenceConfig `yaml:"references" json:"references,omitempty"`
	ProtocolConf      interface{}       `yaml:"protocol_conf" json:"protocol_conf,omitempty"`
}

func GetConsumerConfig

func GetConsumerConfig() ConsumerConfig

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) Service

func (*MockService) Service() string

func (*MockService) Version

func (*MockService) Version() string

type ProtocolConfig

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

type ProviderConfig

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

	ApplicationConfig ApplicationConfig `yaml:"application_config" json:"application_config,omitempty"`
	Registries        []RegistryConfig  `yaml:"registries" json:"registries,omitempty"`
	Services          []ServiceConfig   `yaml:"services" json:"services,omitempty"`
	Protocols         []ProtocolConfig  `yaml:"protocols" json:"protocols,omitempty"`
	ProtocolConf      interface{}       `yaml:"protocol_conf" json:"protocol_conf,omitempty"`
}

func GetProviderConfig

func GetProviderConfig() ProviderConfig

type ReferenceConfig

type ReferenceConfig struct {
	InterfaceName string           `required:"true"  yaml:"interface"  json:"interface,omitempty"`
	Check         *bool            `yaml:"check"  json:"check,omitempty"`
	Url           string           `yaml:"url"  json:"url,omitempty"`
	Filter        string           `yaml:"filter" json:"filter,omitempty"`
	Protocol      string           `yaml:"protocol"  json:"protocol,omitempty"`
	Registries    []ConfigRegistry `required:"true"  yaml:"registries"  json:"registries,omitempty"`
	Cluster       string           `yaml:"cluster"  json:"cluster,omitempty"`
	Loadbalance   string           `yaml:"loadbalance"  json:"loadbalance,omitempty"`
	Retries       int64            `yaml:"retries"  json:"retries,omitempty"`
	Group         string           `yaml:"group"  json:"group,omitempty"`
	Version       string           `yaml:"version"  json:"version,omitempty"`
	Methods       []struct {
		Name        string `yaml:"name"  json:"name,omitempty"`
		Retries     int64  `yaml:"retries"  json:"retries,omitempty"`
		Loadbalance string `yaml:"loadbalance"  json:"loadbalance,omitempty"`
	} `yaml:"methods"  json:"methods,omitempty"`
	// contains filtered or unexported fields
}

func NewReferenceConfig

func NewReferenceConfig(ctx context.Context) *ReferenceConfig

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) Refer

func (refconfig *ReferenceConfig) Refer()

func (*ReferenceConfig) UnmarshalYAML

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

type ReferenceConfigTmp

type ReferenceConfigTmp struct {
	Service    string           `required:"true"  yaml:"service"  json:"service,omitempty"`
	Registries []RegistryConfig `required:"true"  yaml:"registries"  json:"registries,omitempty"`
	URLs       []map[string]string
}

type RegistryConfig

type RegistryConfig struct {
	Id         string `required:"true" yaml:"id"  json:"id,omitempty"`
	Type       string `required:"true" yaml:"type"  json:"type,omitempty"`
	TimeoutStr string `yaml:"timeout" default:"5s" json:"timeout,omitempty"` // unit: second
	Group      string `yaml:"group" json:"group,omitempty"`
	//for registry
	Address  string `yaml:"address" json:"address,omitempty"`
	Username string `yaml:"username" json:"address,omitempty"`
	Password string `yaml:"password" json:"address,omitempty"`
}

type ServiceConfig

type ServiceConfig struct {
	Filter        string           `yaml:"filter" json:"filter,omitempty"`
	Protocol      string           `required:"true"  yaml:"protocol"  json:"protocol,omitempty"` //multi protocol support, split by ','
	InterfaceName string           `required:"true"  yaml:"interface"  json:"interface,omitempty"`
	Registries    []ConfigRegistry `required:"true"  yaml:"registries"  json:"registries,omitempty"`
	Cluster       string           `default:"failover" yaml:"cluster"  json:"cluster,omitempty"`
	Loadbalance   string           `default:"random" yaml:"loadbalance"  json:"loadbalance,omitempty"`
	Group         string           `yaml:"group"  json:"group,omitempty"`
	Version       string           `yaml:"version"  json:"version,omitempty"`
	Methods       []struct {
		Name        string `yaml:"name"  json:"name,omitempty"`
		Retries     int64  `yaml:"retries"  json:"retries,omitempty"`
		Loadbalance string `yaml:"loadbalance"  json:"loadbalance,omitempty"`
		Weight      int64  `yaml:"weight"  json:"weight,omitempty"`
	} `yaml:"methods"  json:"methods,omitempty"`
	Warmup  string `yaml:"warmup"  json:"warmup,omitempty"`
	Retries int64  `yaml:"retries"  json:"retries,omitempty"`
	// contains filtered or unexported fields
}

func NewServiceConfig

func NewServiceConfig() *ServiceConfig

func (*ServiceConfig) Export

func (srvconfig *ServiceConfig) Export() error

func (*ServiceConfig) Implement

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

Jump to

Keyboard shortcuts

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