heroku

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2026 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package heroku provides Console status providers backed by Heroku's Platform API. Provider reports the health of a Heroku app from the state of its dynos (GET /apps/{app}/dynos).

It satisfies the status.Provider interface structurally (Name + Check), so it does not import the status package and adds no coupling beyond core.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*Provider)

Option configures a Provider.

func WithBaseURL

func WithBaseURL(u string) Option

WithBaseURL overrides the Platform API base URL (testing / gateways).

func WithHTTPClient

func WithHTTPClient(c *http.Client) Option

WithHTTPClient sets the HTTP client.

func WithToken

func WithToken(t string) Option

WithToken sets the default API token.

type Provider

type Provider struct {
	// Token is the default Heroku API token, used when a component does not set
	// "api_token". Typically sourced from the HEROKU_API_KEY env var.
	Token string
	// BaseURL is the Platform API base URL; defaults to Heroku's. Overridable for
	// testing or a self-hosted gateway.
	BaseURL string
	// HTTP issues the API request. If nil, a client with a sane timeout is used.
	HTTP *http.Client
}

Provider checks a Heroku app's health from the state of its dynos. The fraction of dynos reporting "up" maps to a health state.

It reads its target from core.Component.Config:

app        required; the Heroku app name
api_token  optional; overrides the provider's default token
timeout    optional; API call timeout as a Go duration, default "10s"

State mapping (over the dynos returned by the API):

all dynos up (and >=1 dyno)         -> StateOperational
at least one up but others not      -> StateDegraded
zero dynos up                       -> StateDown
API/network failure or non-2xx      -> StateDown
no app / token                      -> StateUnknown (configuration gap)
zero dynos returned                 -> StateUnknown (no dynos)

func New

func New(opts ...Option) *Provider

New builds a Provider from options.

func (*Provider) Check

func (p *Provider) Check(ctx context.Context, comp core.Component) core.Check

Check fetches the app's dynos and maps their states to a health state.

func (*Provider) Name

func (p *Provider) Name() string

Name identifies the provider.

Jump to

Keyboard shortcuts

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