Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Notifier

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

    A Notifier sends ServicePing to the Wutai gateways.

    func NewNotifier

    func NewNotifier(pubsub bahamut.PubSubClient, serviceStatusTopic string, serviceName string, endpoint string) *Notifier

      NewNotifier returns a new Wutai notifier.

      func (*Notifier) MakeStartHook

      func (w *Notifier) MakeStartHook(ctx context.Context, frequency time.Duration) func(server bahamut.Server) error

        MakeStartHook returns a bahamut start hook that sends the hello message to the Upstreamer periodically.

        func (*Notifier) MakeStopHook

        func (w *Notifier) MakeStopHook() func(server bahamut.Server) error

          MakeStopHook returns a bahamut stop hook that sends the goodbye message to the Upstreamer.

          type Option

          type Option func(*upstreamConfig)

            An Option represents a configuration option for the Upstreamer.

            func OptionExposePrivateAPIs

            func OptionExposePrivateAPIs(enabled bool) Option

              OptionExposePrivateAPIs configures the Upstreamer to expose the private APIs.

              func OptionOverrideEndpointsAddresses

              func OptionOverrideEndpointsAddresses(override string) Option

                OptionOverrideEndpointsAddresses configures the Upstreamer to always ignore what IP address the services are reporting and always use the provided address.

                func OptionRegisterEventAPI

                func OptionRegisterEventAPI(serviceName string, eventEndpoint string) Option

                  OptionRegisterEventAPI registers an event API for the given serviceName on the given endpoint. For instance is serviceA exposes an event API on /events, you can use

                  OptionRegisterEventAPI("serviceA", "events")
                  

                  func OptionRequiredServices

                  func OptionRequiredServices(required []string) Option

                    OptionRequiredServices sets the list of services that must be ready before starting the upstreamer.

                    func OptionServiceTimeout

                    func OptionServiceTimeout(timeout time.Duration, checkInterval time.Duration) Option

                      OptionServiceTimeout sets the time to wait for the upstream to consider a service that did not ping to be outdated and removed in the case no goodbye was sent. Default is 30s. The check interval parameters defines how often the upstream will check for outdated services. The default is 5s.

                      type Upstreamer

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

                        A Upstreamer listens and update the list of the backend services.

                        func NewUpstreamer

                        func NewUpstreamer(pubsub bahamut.PubSubClient, serviceStatusTopic string, options ...Option) *Upstreamer

                          NewUpstreamer returns a new push backed upstreamer.

                          func (*Upstreamer) Start

                          func (c *Upstreamer) Start(ctx context.Context) chan struct{}

                            Start starts for new backend services.

                            func (*Upstreamer) Upstream

                            func (c *Upstreamer) Upstream(req *http.Request) (string, float64)

                              Upstream returns the upstream to go for the given path