cronitor

package
v1.0.53 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	StateRun      = state{"run"}
	StateComplete = state{"complete"}
	StateFail     = state{"fail"}
)
View Source
var ErrUnexpectedStatusCode = errors.New("cronitor: received unexpected HTTP status code")

Functions

This section is empty.

Types

type Monitor

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

Monitor represents a Cronitor job monitor.

A Monitor with an empty URL behaves as a "no-op Monitor" and does not make HTTP requests.

func New

func New(url string) *Monitor

New creates a new Monitor with the given Cronitor telemetry URL. Panics if "net/url".Parse fails.

Passing the empty string will create a "no-op Monitor" that does not make any HTTP requests.

func (*Monitor) SetState

func (c *Monitor) SetState(state state) error

SetState sets the state of the monitor. Panics if the state transition is not allowed.

If the HTTP request fails or the response status code is not OK, SetState returns an error and the internal state will be reverted to the previous state. If the Monitor is a "no-op Monitor" (i.e. the URL is the empty string), SetState will still advance the internal state of the Monitor.

Jump to

Keyboard shortcuts

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