Documentation ¶
Index ¶
Constants ¶
const ( // RegisterReconcilePeriod is how often the monitor will attempt to // reconcile the expected service state with the remote Consul server. RegisterReconcilePeriod = 30 * time.Second // RegisterTTLPeriod is the TTL setting for the health check of the // service. The monitor will automatically pass the health check // three times per this period to be more resilient to failures. RegisterTTLPeriod = 30 * time.Second )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type FlagUpstreams ¶
type FlagUpstreams map[string]proxy.UpstreamConfig
FlagUpstreams implements the flag.Value interface and allows specifying the -upstream flag multiple times and keeping track of the name of the upstream and the local port.
The syntax of the value is "name:addr" where addr can be "port" or "host:port". Examples: "db:8181", "db:127.0.0.10:8282", etc.
func (*FlagUpstreams) Set ¶
func (f *FlagUpstreams) Set(value string) error
func (*FlagUpstreams) String ¶
func (f *FlagUpstreams) String() string
type RegisterMonitor ¶
type RegisterMonitor struct { // Logger is the logger for the monitor. Logger *log.Logger // Client is the API client to a specific Consul agent. This agent is // where the service will be registered. Client *api.Client // Service is the name of the service being proxied. Service string // LocalAddress and LocalPort are the address and port of the proxy // itself, NOT the service being proxied. LocalAddress string LocalPort int // IDSuffix is a unique ID that is appended to the end of the service // name. This helps the service be unique. By default the service ID // is just the proxied service name followed by "-proxy". IDSuffix string // The fields below are related to timing settings. See the default // constants for more documentation on what they set. ReconcilePeriod time.Duration TTLPeriod time.Duration // contains filtered or unexported fields }
RegisterMonitor registers the proxy with the local Consul agent with a TTL health check that is kept alive.
This struct should be intialized with NewRegisterMonitor instead of being allocated directly. Using this struct without calling NewRegisterMonitor will result in panics.
func NewRegisterMonitor ¶
func NewRegisterMonitor() *RegisterMonitor
NewRegisterMonitor initializes a RegisterMonitor. After initialization, the exported fields should be configured as desired. To start the monitor, execute Run in a goroutine.
func (*RegisterMonitor) Close ¶
func (r *RegisterMonitor) Close() error
Close stops the register goroutines and deregisters the service. Once Close is called, the monitor can no longer be used again. It is safe to call Close multiple times and concurrently.
func (*RegisterMonitor) Run ¶
func (r *RegisterMonitor) Run()
Run should be started in a goroutine and will keep Consul updated in the background with the state of this proxy. If registration fails this will continue to retry.