topster

package
v0.0.0-...-3f13264 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrChartOption = errors.New("topster: invalid chart option")

ErrChartOption is returned when an invalid chart option is set.

Functions

This section is empty.

Types

type ChartOption

type ChartOption func(*chartOptions)

ChartOption configures a chart.

func BackgroundColor

func BackgroundColor(bgc string) ChartOption

BackgroundColor sets a chart's background color.

func Gap

func Gap(gap float64) ChartOption

Gap sets a chart's gap.

func Period

func Period(period string) ChartOption

Period sets a chart's period.

func ShowNumbers

func ShowNumbers() ChartOption

ShowNumbers enables showing numbers on a chart.

func ShowTitles

func ShowTitles() ChartOption

ShowTitles enables showing titles on a chart.

func TextColor

func TextColor(tc string) ChartOption

TextColor sets a chart's text color.

func Title

func Title(title string) ChartOption

Title sets a chart's title.

type Client

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

Client is an API client that interacts with a companion microgopster instance.

func New

func New(addr string, opts ...Option) (*Client, error)

New creates a new Topster client.

func (*Client) CreateChart

func (t *Client) CreateChart(ctx context.Context, user string, opts ...ChartOption) (string, error)

CreateChart creates a chart using the configured microgopster instance and returns it as a Base64 encoded string.

type Error

type Error struct {
	HTTPStatus int    `json:"-"`
	Message    string `json:"message"`
}

Error is an error sent by a microgopster instance.

func (*Error) Error

func (e *Error) Error() string

Error implements the error interface.

type Option

type Option func(*Client)

Option configures a Topster client.

func WithHTTPClient

func WithHTTPClient(client *http.Client) Option

WithHTTPClient sets a Topster client's underlying HTTP client.

Jump to

Keyboard shortcuts

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