tchannel-go: github.com/uber/tchannel-go/hyperbahn Index | Files | Directories

package hyperbahn

import "github.com/uber/tchannel-go/hyperbahn"

Index

Package Files

advertise.go call.go client.go configuration.go discover.go event_string.go events.go utils.go

type AdRequest Uses

type AdRequest struct {
    Services []service `json:"services"`
}

AdRequest is the Ad request sent to Hyperbahn.

type AdResponse Uses

type AdResponse struct {
    ConnectionCount int `json:"connectionCount"`
}

AdResponse is the Ad response from Hyperbahn.

type Client Uses

type Client struct {
    // contains filtered or unexported fields
}

Client manages Hyperbahn connections and registrations.

func NewClient Uses

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 Uses

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 Uses

func (c *Client) Close()

Close closes the Hyperbahn client, which stops any background re-advertisements.

func (*Client) Discover Uses

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 Uses

func (c *Client) IsClosed() bool

IsClosed returns whether this Client is closed.

type ClientOptions Uses

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

    // The following are variables for stubbing in unit tests.
    // They are not part of the stable API and may change.
    TimeSleep func(d time.Duration)
}

ClientOptions are used to configure this Hyperbahn client.

type Configuration Uses

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 Uses

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 Uses

func (e ErrAdvertiseFailed) Error() string

type Event Uses

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
)

func (Event) String Uses

func (i Event) String() string

type FailStrategy Uses

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) UnmarshalText Uses

func (f *FailStrategy) UnmarshalText(text []byte) error

UnmarshalText implements encoding/text.Unmarshaler. This allows FailStrategy to be specified as a string in many file formats (e.g. JSON, YAML, TOML).

type Handler Uses

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.

Directories

PathSynopsis
gen-go/hyperbahnPackage hyperbahn is generated code used to make or handle TChannel calls using Thrift.

Package hyperbahn imports 12 packages (graph) and is imported by 12 packages. Updated 2019-08-02. Refresh now. Tools for package owners.