config

package
v0.0.0-...-7904037 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2024 License: EPL-1.0 Imports: 12 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDefaultInstance

func NewDefaultInstance() *core.Instance

NewInstance 创建服务实例

func NewInstance

func NewInstance(config *Config) (*core.Instance, error)

Types

type AppConfig

type AppConfig struct {
	Server struct {
		Port int `yaml:"port"`
	} `yaml:"server"`
	Eureka Config `yaml:"eureka"`
}

type ClientConfig

type ClientConfig struct {
	//指示从eureka服务器获取注册表信息的频率,默认30s
	RegistryFetchIntervalSeconds int `yaml:"registryFetchIntervalSeconds"`
	//客户端是否获取eureka服务器注册表上的注册信息,不调用其他微服务可以为false,默认为false
	FetchRegistry bool `yaml:"fetchRegistry"`
	//是否过滤掉非up实例,默认为false
	FilterOnlyUpInstances bool `yaml:"filterOnlyUpInstances"`
	//指示此实例是否应将其信息注册到eureka服务器以供其他服务发现,默认为false
	RegisterWithEureka bool `yaml:"registerWithEureka"`
	//client在shutdown情况下,是否显示从注册中心注销
	ShouldUnregisterOnShutdown bool `yaml:"shouldUnregisterOnShutdown"`
}

func (*ClientConfig) GetRegistryFetchIntervalSeconds

func (config *ClientConfig) GetRegistryFetchIntervalSeconds() int

指示从eureka服务器获取注册表信息的频率,默认30秒

type Config

type Config struct {
	ServiceURL struct {
		DefaultZone string `yaml:"defaultZone"`
	} `yaml:"serviceUrl"`
	ClientConfig   ClientConfig `yaml:"client"`
	InstanceConfig struct {
		InstanceId            string `yaml:"instanceId"`
		AppName               string `yaml:"appName"`
		NonSecurePort         int    `yaml:"nonSecurePort"`
		NonSecurePortEnabled  bool   `yaml:"nonSecurePortEnabled"`
		SecurePort            int    `yaml:"securePort"`
		SecurePortEnabled     bool   `yaml:"securePortEnabled"`
		SecureVirtualHostName string `yaml:"secureVirtualHostName"`
		VirtualHostName       string `yaml:"virtualHostName"`
		//
		HomePageUrlPath    string `yaml:"homePageUrlPath"`
		StatusPageUrlPath  string `yaml:"statusPageUrlPath"`
		HealthCheckUrlPath string `yaml:"healthCheckUrlPath"`
		//
		PreferIpAddress       bool `yaml:"preferIpAddress"`
		InstanceEnabledOnInit bool `yaml:"instanceEnabledOnInit"`
		//
		CountryId int                    `yaml:"countryId"`
		Metadata  map[string]interface{} `yaml:"metadata"`
		LeaseInfo struct {
			RenewalIntervalInSecs int `yaml:"renewalIntervalInSecs"`
			DurationInSecs        int `yaml:"durationInSecs"`
		} `yaml:"leaseInfo"`
	} `yaml:"instance"`
}

see: https://www.cnblogs.com/liukaifeng/p/10052594.html

func LoadConfig

func LoadConfig(configPath string, valid bool) (*Config, error)

Jump to

Keyboard shortcuts

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