Version: v0.4.1 Latest Latest

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

Go to latest
Published: Mar 14, 2016 License: MIT, MIT Imports: 12 Imported by: 0




This section is empty.


This section is empty.


This section is empty.


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

func (c *Client) Advertise(otherServices ...tchannel.Registrar) error

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.

func (*Client) Discover

func (c *Client) Discover(serviceName string) ([]string, error)

Discover queries Hyperbahn for a list of peers that are currently advertised with the specified service name.

func (*Client) IsClosed

func (c *Client) IsClosed() bool

IsClosed returns whether this Client is closed.

type ClientOptions

type ClientOptions struct {
	// Timeout defaults to 3 seconds if it is not set.
	Timeout time.Duration
	// TimeoutPerAttempt defaults to 1 second if it is not set.
	TimeoutPerAttempt 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.
	// Advertised is triggered when the initial advertisement for a service is successful.
	// Readvertised is triggered on periodic advertisements.

func (Event) String

func (i Event) String() string

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.

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.

type Handler

type Handler interface {
	// On is called when events are triggered.
	On(event Event)
	// OnError is called when an error is detected.
	OnError(err error)

Handler is the interface for handling Hyperbahn events and errors.


Path Synopsis
Package hyperbahn is generated code used to make or handle TChannel calls using Thrift.
Package hyperbahn is generated code used to make or handle TChannel calls using Thrift.

Jump to

Keyboard shortcuts

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