discovery

package
v0.0.0-...-2efaa0c Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2018 License: Apache-2.0 Imports: 8 Imported by: 1

README

Discovery GoDoc

Discovery builds on the go-micro.Registry and is backed by the Micro OS discovery service.

The go-micro registry provides a simple Registry abstraction for various service discovery systems. Heartbeating is also done through a simple form of re-registration. Because of this we end up with a system that has limited scaling potential and does not provide much information about service health.

Discovery provides heartbeating as events published via the Broker. This means anyone can subscribe to the heartbeats to determine "liveness" rather than querying the Registry. Discovery also includes an in-memory cache of the Registry using the Watcher. If the Registry fails for any reason Discovery continues to function.

Interface

// Discovery builds on the registry as a mechanism
// for finding services. It includes heartbeating
// to notify of liveness and caching of the registry.
type Discovery interface {
	// implements the registry interface
	registry.Registry
	Close() error
}

func NewDiscovery(opts ...registry.Option) Discovery {
	return newOS(opts...)
}

## Supported Backends

Usage

With Flag
import _ "github.com/micro/go-os/discovery"
go run main.go --registry=os --registry_address=addr1:port,addr2:port,addr3:port
Direct Use
import (
	"github.com/micro/go-micro"
	"github.com/micro/go-os/discovery"
)

func main() {
	r := discovery.NewDiscovery(
		discovery.Addrs("addr1:port", "addr2:port", "addr3:port"),
	)

	service := micro.NewService(
		micro.Name("my.service"),
		micro.Registry(r),
	)
}

Documentation

Overview

Package discovery is an interface for scalable service discovery.

Index

Constants

View Source
const (
	HeartbeatTopic = "micro.discovery.heartbeat"
)

Variables

This section is empty.

Functions

func Client

func Client(c client.Client) registry.Option

Client used to call the discovery service

func Interval

func Interval(i time.Duration) registry.Option

Interval on which to publish heartbeats

func NewContext

func NewContext(ctx context.Context, c Discovery) context.Context

func NewRegistry

func NewRegistry(opts ...registry.Option) registry.Registry

Types

type Discovery

type Discovery interface {
	Close() error
	registry.Registry
}

Discovery builds on the registry for heartbeating and client side caching

func FromContext

func FromContext(ctx context.Context) (Discovery, bool)

func NewDiscovery

func NewDiscovery(opts ...registry.Option) Discovery

type Options

type Options struct {
	Client   client.Client
	Interval time.Duration
}

Options holds discovery options stored in registry Options context

Directories

Path Synopsis
Package go_micro_os_discovery is a generated protocol buffer package.
Package go_micro_os_discovery is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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