Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AdRequest ¶
type AdRequest struct {
Services []service `json:"services"`
}
AdRequest is the Ad request sent to Hyperbahn.
type AdResponse ¶
type AdResponse struct {
ConnectionCount int `json:"connectionCount"`
}
AdResponse is the Ad response from Hyperbahn.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client manages Hyperbahn connections and registrations.
func NewClient ¶
func NewClient(ch *tchannel.Channel, config Configuration, opts *ClientOptions) (*Client, error)
NewClient creates a new Hyperbahn client using the given channel. config is the environment-specific configuration for Hyperbahn such as the list of initial nodes. opts are optional, and are used to customize the client.
func (*Client) Advertise ¶
Advertise advertises the service with Hyperbahn, and returns any errors on initial advertisement. Advertise can register multiple services hosted on the same endpoint. If the advertisement succeeds, a goroutine is started to re-advertise periodically.
func (*Client) Close ¶
func (c *Client) Close()
Close closes the Hyperbahn client, which stops any background re-advertisements.
type ClientOptions ¶
type ClientOptions struct { // Timeout defaults to 1 second if it is not set. Timeout time.Duration Handler Handler FailStrategy FailStrategy }
ClientOptions are used to configure this Hyperbahn client.
type Configuration ¶
type Configuration struct { // InitialNodes is the list of known Hyperbahn nodes to add initially. InitialNodes []string // InitialNodesFile is a JSON file that contains the list of known Hyperbahn nodes. // If this option is set, it overrides InitialNodes. InitialNodesFile string }
Configuration is the initial configuration
type ErrAdvertiseFailed ¶
type ErrAdvertiseFailed struct { // WillRetry is set to true if advertise will be retried. WillRetry bool // Cause is the underlying error returned from the advertise call. Cause error }
ErrAdvertiseFailed is triggered when advertise fails.
func (ErrAdvertiseFailed) Error ¶
func (e ErrAdvertiseFailed) Error() string
type Event ¶
type Event int
Event describes different events that Client can trigger.
const ( // UnknownEvent should never be used. UnknownEvent Event = iota // SendAdvertise is triggered when the Hyperbahn client tries to advertise. SendAdvertise // Advertised is triggered when the initial advertisement for a service is successful. Advertised // Readvertised is triggered on periodic advertisements. Readvertised )
type FailStrategy ¶
type FailStrategy int
FailStrategy is the strategy to use when registration fails maxRegistrationFailures times consecutively in the background. This is not used if the initial registration fails.
const ( // FailStrategyFatal will call Fatalf on the channel's logger after triggering handler.OnError. // This is the default strategy. FailStrategyFatal FailStrategy = iota // FailStrategyIgnore will only call handler.OnError, even after many // errors, and will continue to retry forever. FailStrategyIgnore )
func (*FailStrategy) UnmarshalYAML ¶
func (f *FailStrategy) UnmarshalYAML(unmarshal func(v interface{}) error) error
UnmarshalYAML implements the yaml.UnmarshalYAML interface. This allows FailStrategy to be specified as a string (e.g. "fatal") in configuration files.