gohealthchecks

package module
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: May 5, 2023 License: MIT Imports: 10 Imported by: 1

README

PkgGoDev Test workflow Go Report Codecov
Become a sponsor Donate Paypal

About

Go client library for accessing the Healthchecks API.

Installation

go get github.com/crazy-max/gohealthchecks

Usage

package main

import (
	"context"
	"log"
	"net/url"

	"github.com/crazy-max/gohealthchecks"
)

func main() {
	var err error
	
	// Default client uses https://hc-ping.com/
	// client := gohealthchecks.NewClient(nil)

	hcBaseURL, err := url.Parse("https://hc.foo.com")
	if err != nil {
		log.Fatal(err)
	}
	client := gohealthchecks.NewClient(&gohealthchecks.ClientOptions{
		BaseURL: hcBaseURL,
	})

	err = client.Start(context.Background(), gohealthchecks.PingingOptions{
		UUID: "5bf66975-d4c7-4bf5-bcc8-b8d8a82ea278",
		Logs: "Job started!",
	})
	if err != nil {
		log.Fatal(err)
	}

	err = client.Success(context.Background(), gohealthchecks.PingingOptions{
		UUID: "5bf66975-d4c7-4bf5-bcc8-b8d8a82ea278",
		Logs: "Job completed!",
	})
	if err != nil {
		log.Fatal(err)
	}

	err = client.Fail(context.Background(), gohealthchecks.PingingOptions{
		UUID: "5bf66975-d4c7-4bf5-bcc8-b8d8a82ea278",
		Logs: "Job failed...",
	})
	if err != nil {
		log.Fatal(err)
	}
}

Contributing

Want to contribute? Awesome! The most basic way to show your support is to star the project, or to raise issues. You can also support this project by becoming a sponsor on GitHub or by making a Paypal donation to ensure this journey continues indefinitely!

Thanks again for your support, it is much appreciated! 🙏

License

MIT. See LICENSE for more details.

Documentation

Overview

Go client library for accessing the Healthchecks API.

Get started:

func main() {
  var err error
  client := gohealthchecks.NewClient(nil)

  err = client.Start(context.Background(), gohealthchecks.PingingOptions{
    UUID: "5bf66975-d4c7-4bf5-bcc8-b8d8a82ea278",
    Logs: "Job started!",
  })
  if err != nil {
    log.Fatal(err)
  }

  err = client.Success(context.Background(), gohealthchecks.PingingOptions{
    UUID: "5bf66975-d4c7-4bf5-bcc8-b8d8a82ea278",
    Logs: "Job completed!",
  })
  if err != nil {
    log.Fatal(err)
  }

  err = client.Fail(context.Background(), gohealthchecks.PingingOptions{
    UUID: "5bf66975-d4c7-4bf5-bcc8-b8d8a82ea278",
    Logs: "Job failed...",
  })
  if err != nil {
    log.Fatal(err)
  }
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client manages communication with the Healthchecks API.

func NewClient

func NewClient(o *ClientOptions) *Client

NewClient constructs a new Client.

func (*Client) Fail

func (c *Client) Fail(ctx context.Context, po PingingOptions) (err error)

Fail sends a fail request to Healthchecks to indicate that an error has occurred.

func (*Client) Start

func (c *Client) Start(ctx context.Context, po PingingOptions) (err error)

Start sends a start request to Healthchecks to indicate that a job has started.

func (*Client) Success

func (c *Client) Success(ctx context.Context, po PingingOptions) (err error)

Success sends a success request to Healthchecks to indicate that a job has completed.

type ClientOptions

type ClientOptions struct {
	HTTPClient *http.Client
	BaseURL    *url.URL
}

ClientOptions holds optional parameters for the Client.

type PingingOptions

type PingingOptions struct {
	UUID string
	Logs string
}

PingingOptions holds parameters for the Pinging API.

Jump to

Keyboard shortcuts

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