Documentation ¶
Index ¶
- Constants
- Variables
- type ConsulHealth
- type Hub
- func (h *Hub) ConnectToService(ctx context.Context, target *pb.ServiceRoute, account *pb.Account, ...) (wire.Context, error)
- func (hub *Hub) ListenHTTP(addr string) error
- func (hub *Hub) Run(ctx context.Context, li net.Listener) error
- func (h *Hub) Serve(ctx context.Context, l net.Listener) error
- func (h *Hub) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (h *Hub) ValidateToken(stoken string) (*token.ValidToken, error)
- func (hub *Hub) WaitToDrain() error
Constants ¶
const ServicesPerAccount = 100
Variables ¶
var ( // The maximum time to run a blocking query to the catalog for. DefaultRefreshTime = 30 * time.Second // How long to configured the consul TTL check with. This is the maximum time // the service has to update it's TTL again before it's marked as failed. CheckTTL = "30s" // ConsulService is the service name that is used to identify hubs. Each // instance of ConsulHealth identifies itself as a separate instance of this service. ConsulService = "hub" )
var ( ErrProtocolError = errors.New("protocol error") ErrWrongService = errors.New("wrong service") ErrTooManyServices = errors.New("too many services per account") )
var ErrNoAvailableAddresses = errors.New("no addresses available for hub")
var ErrNoRoutes = errors.New("no routes to any service available")
var ErrNoSuchSession = errors.New("no session found")
Functions ¶
This section is empty.
Types ¶
type ConsulHealth ¶
type ConsulHealth struct {
// contains filtered or unexported fields
}
ConsulHealth advertises an instance of the hub service to consul and also monitors the service catalog for other instances. It provides the ability for each hub to know which other hubs are currently available to send traffic to.
func NewConsulHealth ¶
func NewConsulHealth(id string, cfg *consul.Config) (*ConsulHealth, error)
NewConsulHealth creates a ConsulHealth instance, identified by id.
func (*ConsulHealth) Available ¶
func (c *ConsulHealth) Available(id string) bool
Available checks the local catalog cache and indicates if the given hub is currently available.
func (*ConsulHealth) Start ¶
func (c *ConsulHealth) Start(ctx context.Context, L hclog.Logger) error
Start registers the service, begins updating the TTL check, and runs Watch to update the local catalog view in the background.
func (*ConsulHealth) Watch ¶
func (c *ConsulHealth) Watch(ctx context.Context, refreshTime time.Duration)
Watch runs forever, updating the local view of all hub instances. refreshTime controls how often the refresh queries wait for updates before trying again. The lower the value, the more this function will loop internally.
type Hub ¶
type Hub struct { L hclog.Logger // contains filtered or unexported fields }
func (*Hub) ConnectToService ¶
func (*Hub) ListenHTTP ¶
func (*Hub) ValidateToken ¶
func (h *Hub) ValidateToken(stoken string) (*token.ValidToken, error)