announcer

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: May 13, 2021 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package announcer encapsulates the idea of a server that dynamically advertises its presence to clients through various media.

Typical usage:

// On startup:
var a announcer.Announcer
impl, err := announcer.NewFoo(...)
// check err
a.Add(impl)

// When ready to serve:
err = a.Announce(ctx, &membership.Roxy{
	Ready:       true,
	IP:          ipAddr,
	ServerName:  "myserver.example.com", // name on your TLS certificate
	PrimaryPort: mainPort,
	AdditionalPorts: map[string]uint16{
		"foo": fooPort,
		"bar": barPort,
	},
})
// check err

// When about to stop serving:
err = a.Withdraw(ctx)
// check err

// On exit:
err = a.Close()
// check err

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Announcer

type Announcer struct {
	// contains filtered or unexported fields
}

func New

func New() *Announcer

func (*Announcer) Add

func (a *Announcer) Add(impl Impl)

func (*Announcer) Announce

func (a *Announcer) Announce(ctx context.Context, r *membership.Roxy) error

func (*Announcer) Close

func (a *Announcer) Close() error

func (*Announcer) Withdraw

func (a *Announcer) Withdraw(ctx context.Context) error

type Format

type Format uint8
const (
	RoxyFormat Format = iota
	FinagleFormat
	GRPCFormat
)

func (Format) MarshalJSON

func (f Format) MarshalJSON() ([]byte, error)

func (*Format) Parse

func (f *Format) Parse(str string) error

func (Format) String

func (f Format) String() string

func (*Format) UnmarshalJSON

func (f *Format) UnmarshalJSON(raw []byte) error

type Impl

type Impl interface {
	Announce(ctx context.Context, r *membership.Roxy) error
	Withdraw(ctx context.Context) error
	Close() error
}

func NewATC

func NewATC(client *atcclient.ATCClient, serviceName, location, unique, namedPort string, loadFn atcclient.LoadFunc) (Impl, error)

func NewEtcd

func NewEtcd(etcd *v3.Client, path, unique, namedPort string, format Format) (Impl, error)

func NewZK

func NewZK(zkconn *zk.Conn, path, unique, namedPort string, format Format) (Impl, error)

Jump to

Keyboard shortcuts

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