discovery-srv

command module
v0.0.0-...-4a97e6e Latest Latest
Warning

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

Go to latest
Published: May 16, 2016 License: Apache-2.0 Imports: 6 Imported by: 0

README

Discovery Server

Discovery server is a microservice which layers on the registry to provide heartbeating, in memory caching and much more. It subscribes to heartbeats and maintains a registry based on liveness.

It's built with the Eureka 2.0 design in mind. The Discovery service acts as a read layer cache where the usage of a Registry like Consul, Etcd, Zookeeper act as the write layer. With the combination of the Registry, Discovery and Platform we can develop a highly available discovery system.

Getting started

  1. Install Consul

    Consul is the default registry/discovery for go-micro apps. It's however pluggable. https://www.consul.io/intro/getting-started/install.html

  2. Run Consul

    $ consul agent -server -bootstrap-expect 1 -data-dir /tmp/consul
    
  3. Download and start the service

    go get github.com/micro/discovery-srv
    discovery-srv
    

    OR as a docker container

    docker run microhq/discovery-srv --registry_address=YOUR_REGISTRY_ADDRESS
    

The API

Discovery server implements the following RPC Methods

Discovery.Heartbeats
micro query go.micro.srv.discovery Discovery.Heartbeats
{
	"heartbeats": [
		{
			"id": "foo-123",
			"interval": 1,
			"service": {
				"endpoints": [
					{
						"metadata": {
							"index": "Handles index requests"
						},
						"name": "/index",
						"request": {
							"name": "request",
							"type": "Request"
						},
						"response": {
							"name": "response",
							"type": "Response"
						}
					}
				],
				"metadata": {
					"foo": "bar"
				},
				"name": "go.micro.srv.foo",
				"nodes": [
					{
						"address": "localhost",
						"id": "foo-123",
						"metadata": {
							"bar": "baz"
						},
						"port": 8080
					}
				],
				"version": "latest"
			},
			"timestamp": 1.451177551e+09,
			"ttl": 5
		}
	]
}
Discovery.Endpoints
micro query go.micro.srv.discovery Discovery.Endpoints
{
	"endpoints": [
		{
			"endpoint": {
				"metadata": {
					"index": "Handles index requests"
				},
				"name": "/index",
				"request": {
					"name": "request",
					"type": "Request"
				},
				"response": {
					"name": "response",
					"type": "Response"
				}
			},
			"service": "go.micro.srv.foo",
			"version": "latest"
		}
	]
}
Sending Heartbeats

Heartbeats are sent to the discovery service using go-platform/discovery

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
proto
discovery
Package go_micro_srv_discovery_discovery is a generated protocol buffer package.
Package go_micro_srv_discovery_discovery is a generated protocol buffer package.
registry
Package go_micro_srv_discovery_registry is a generated protocol buffer package.
Package go_micro_srv_discovery_registry is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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