Documentation
¶
Overview ¶
Package discovery provides service discovery for the KumuluzEE microservice framework.
Index ¶
Constants ¶
const ( AccessTypeDirect = "direct" AccessTypeGateway = "gateway" )
Possible access types for DiscoverOptions.AccessType
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DiscoverOptions ¶
type DiscoverOptions struct { // Name of the service to discover. Value string // Environment of the service to discover. // If value is not provided, it uses value from configuration with key kumuluzee.env.name // If value is not specified and key in configuration does not exists, value defaults to 'dev'. Environment string // Version of the service to discover. // Supported values are semantic version (semver) parseable versions/version ranges. // Default value is "*", which resolves to highest deployed version. Version string // AccessType defines, which URL gets injected. // Supported values are constants discovery.AccessTypeGateway and discovery.AccessTypeDirect. // Default value is discovery.AccessTypeGateway. AccessType string }
DiscoverOptions is used when discovering services
type Options ¶
type Options struct { // Additional configuration source to connect to. Possible values are: "consul", "etcd" Extension string // ConfigPath is a path to configuration file, including the configuration file name. // Passing an empty string will default to config/config.yaml ConfigPath string // LogLevel can be used to limit the amount of logging output. Default log level is 0. Level 4 // will only output Warnings and Errors, and level 5 will only output errors. // See package github.com/mc0239/logm for more details on logging and log levels. LogLevel int }
Options struct is used when instantiating a new Util.
type RegisterOptions ¶
type RegisterOptions struct { // Service name to register the service by. // Can be overridden with configuration key kumuluzee.name Value string // Time to live of a registration key in the store (in seconds). // Default value is 30. // Can be overridden with configuration key kumuluzee.discovery.ttl TTL int64 // Interval in which service updates registration key value in store. // Default value is 20. // Can be overridden with configuration key kumuluzee.discovery.ping-interval PingInterval int64 // Environment in which the service is registered. // Default value is "dev". // Can be overridden with configuration key kumuluzee.env.name Environment string // Version of the service to be registered. // Default value is "1.0.0". // Can be overridden with configuration key kumuluzee.version Version string // If set to true, only once instance of service with the same name, version and environment is registered. // Default value is false. Singleton bool }
RegisterOptions is used when registering a service
type Util ¶
Util is used for registering and discovering services from a service discovery source. Util should be initialized with discovery.New() function
func (Util) DeregisterService ¶
DeregisterService removes service from the registry (deregisters).
func (Util) DiscoverService ¶
func (d Util) DiscoverService(options DiscoverOptions) (string, error)
DiscoverService discovery services using service discovery client with given RegisterOptions
func (Util) RegisterService ¶
func (d Util) RegisterService(options RegisterOptions) (string, error)
RegisterService registers service using service discovery client with given RegisterOptions