Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Decoder ¶
type Decoder struct { // Target is the target structure for configuration to be written to. // After supplying this configuration option, you should never write to // this value again. When configuration changes are detected, Decoder // will deep copy this structure before writing any changes and sending // them on UpdateCh. Target interface{} // Prefix is the key prefix in Consul where data will live. Decoder // will perform a blocking list query on this prefix and will also // request ALL DATA in this prefix. Be very careful that this prefix // contains only the configuration data for this application. // // A prefix of "" is not allowed, since that will request all data in // Consul and should never be used as the configuration root. // // If Prefix doesn't end in '/', then it will be appended. The Decoder // treats '/' as the path separator in Consul. This is used to find // nested values as well. Prefix string // UpdateCh is the channel where updates to the configuration are sent. // An initial value will be sent on the first read of data from Consul. // // The value sent on UpdateCh is initially a deep copy of Target so // there are no race issues around reading/writing values that come // on this channel. // // ErrCh is sent errors that the Decoder experiences. The Decoder // will otherwise ignore errors and continue running in an attempt to // stabilize, but you can choose to log or exit on errors if you'd // like. Temporary errors such as network issues aren't ever reported. UpdateCh chan<- interface{} ErrCh chan<- error // QuiescencePeriod is the period of time to wait for Consul changes // to quiesce (achieve a stable, unchanging state) before triggering // an update. // // QuiescenceTimeout is the max time to wait for the QuiescencePeriod // to be reached before forcing an update anyways. For example, if // Period is set to 500ms and Timeout is set to 5s, then if data is // continously being updated for over 5s (causing the Period to never // be reached), the decoder will trigger an update anyways. // // If neither of these is set, they will default to 500ms and 5s, // respectively. QuiescencePeriod time.Duration QuiescenceTimeout time.Duration // Consul is the configuration to use for initializing the Consul client. // If this is nil, then a default configuration will be used that // accesses Consul locally without any ACL token. For default values, // see consul.DefaultConfig. Consul *consul.Config // contains filtered or unexported fields }
Decoder is the structure for decoding Consul data into a Go structure.
Please read the documentation carefully for each field. Fields that aren't set properly can result in broken behavior.
See Run for information on how to start the Decoder.
func (*Decoder) Close ¶
Close stops any running Run method. If none are running, this does nothing. Otherwise, this will block until it stops. After Close is called, Run can be started again at any time.
This could really be named "Stop" but we have implemented it as Close so that it implements io.Closer.
Click to show internal directories.
Click to hide internal directories.