portmapper

package module
v0.0.0-...-b0d47bf Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2017 License: MIT Imports: 8 Imported by: 4

README

portmapper

A portmapper backed by etcd v2.

Testing

  • Set the environmental variable PORTMAPPER_ETCD_HOST="http://etcd-docker-ip"
  • Run docker-compose up
  • go test

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// RegistryPath sets the location in etcd where portmapper will store data.
	// Default: /opsee.co/portmapper
	EtcdHost     = "http://127.0.0.1:2379"
	RegistryPath = "/opsee.co/portmapper"

	// max retries for exponential backoff
	MaxRetries                      = 3
	RequestTimeoutSec time.Duration = 5
)

Functions

func Register

func Register(name string, port int) error

Register a service with etcd

func Unregister

func Unregister(name string, port int) error

Unregister a (service, port) tuple.

Types

type Service

type Service struct {
	Name     string `json:"name"`
	Port     int    `json:"port"`
	Hostname string `json:"hostname,omitempty"`
}

Service is a mapping between a service name and port. It may also contain the hostname where the service is running or the container ID in the Hostname field. It will attempt to get this from the HOSTNAME environment variable.

func Services

func Services() ([]*Service, error)

Services returns an array of Service pointers detailing the service name and port of each registered service. (from etcd)

func UnmarshalService

func UnmarshalService(bytes []byte) (*Service, error)

UnmarshalService deserializes a Service object from a byte array.

func (*Service) Marshal

func (s *Service) Marshal() ([]byte, error)

Marshal a service object to a byte array.

Jump to

Keyboard shortcuts

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