discovery

package
v0.0.0-...-4ad99ce Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2019 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package discovery provides service discovery for the KumuluzEE microservice framework.

Index

Constants

View Source
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

type Util struct {
	Logger logm.Logm
	// contains filtered or unexported fields
}

Util is used for registering and discovering services from a service discovery source. Util should be initialized with discovery.New() function

func New

func New(options Options) Util

New instantiates Util struct with initialized service discovery

func (Util) DeregisterService

func (d Util) DeregisterService() error

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

Jump to

Keyboard shortcuts

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