Skip to content
A discovery service for microservices
Go Protocol Buffer
Find file
Latest commit 759a48f @asim asim Strip glog
Failed to load latest commit information.
discovery Strip glog
handler Eliminate a data race
proto Name proto packages
Dockerfile update docker file
LICENSE First
README.md Update readme
main.go Strip glog

README.md

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.

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

Something went wrong with that request. Please try again.