srv

package module
v0.0.0-...-34ee1ce Latest Latest
Warning

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

Go to latest
Published: May 3, 2017 License: MIT Imports: 5 Imported by: 0

README

SRV

This is a simple naming resolver that helps resolve SRV DNS records. This is useful for when your running service discovery that's exposed through DNS.

Example

Using standard consul SRV DNS

package main

// exposes the 'srv' package namespace
import "github.com/vectorhacker/go-srv"

func main() {
  changes := srv.Resolver.Resolve("hello.service.consul")

  // Blocks until you get the next set of changes or an error
  addrs, err := changes.Next()

  if err != nil {
    panic(err)
  }

  con, err := net.Dial("tcp", addrs[0].Addr)
  if err != nil {
    // handle error
  }
  fmt.Fprintf(conn, "GET / HTTP/1.0\r\n\r\n")
  status, err := bufio.NewReader(conn).ReadString('\n')

  // ...

  // Closes the watcher
  changes.Close()
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Resolver = ResolverFunc(resolver)

Resolver implements the ResolverFunc interface

Functions

func NewWatcher

func NewWatcher(target string) naming.Watcher

NewWatcher returns a naming.Watcher that watches for changes on the SRV records of the target address string

Types

type ResolverFunc

type ResolverFunc func(target string) (naming.Watcher, error)

ResolverFunc implements the naming.Resolver interface

func (ResolverFunc) Resolve

func (f ResolverFunc) Resolve(target string) (naming.Watcher, error)

Resolve calls the ResolverFunc

Jump to

Keyboard shortcuts

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