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 ¶
- type Announcer
- type Format
- type Interface
- func NewATC(client *atcclient.ATCClient, serviceName, location, unique, namedPort string, ...) (Interface, error)
- func NewEtcd(etcd *v3.Client, path, unique, namedPort string, format Format) (Interface, error)
- func NewZK(zkconn *zk.Conn, path, unique, namedPort string, format Format) (Interface, error)
- type State
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
}
Announcer is a multiplexer implementation of Interface that distributes method calls to multiple announcers.
func (*Announcer) Add ¶
Add adds a child announcer. Both Announcer and the child announcer must be in the ready state, or Add will panic.
func (*Announcer) Announce ¶
Announce broadcasts to all child announcers that the service is available at the given address.
Announcer must be in the ready state, or Announce will panic. A successful call to this method changes Announcer's state from the ready state to the running state.
func (*Announcer) Close ¶
Close broadcasts to all child announcers that no further announcements are coming and that they should clean up any resources.
If Announcer is already in the closed state, nothing is done and fs.ErrClosed is returned. If Announcer is in neither the ready state nor the closed state, Close will panic. Any call to this method changes Announcer's state to the closed state.
type Format ¶
type Format uint8
func (Format) MarshalJSON ¶
MarshalJSON fulfills json.Marshaler.
func (*Format) UnmarshalJSON ¶
UnmarshalJSON fulfills json.Unmarshaler.
type Interface ¶ added in v0.4.3
type Interface interface { Announce(ctx context.Context, r *membership.Roxy) error Withdraw(ctx context.Context) error Close() error }
Interface is the interface provided by announcers for specific protocols.
type State ¶ added in v0.4.3
type State uint8
State is used to keep track of which Announcer methods have been called.