utils

package
v0.0.0-...-cd8557d Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package utils contains helper functions and structs

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterWorkers

func RegisterWorkers(conf Config)

RegisterWorkers registers all jobs in the config file as workers

func SetupLogger

func SetupLogger() (logger *zap.Logger)

SetupLogger sets up a zap logger with default settings

func SetupSugaredLogger

func SetupSugaredLogger() (sugaredLogger *zap.SugaredLogger)

SetupSugaredLogger sets up a zap sugared logger with default settings

Types

type Config

type Config struct {
	Version string `yaml:"version"`
	Jobs    []Job  `yaml:"jobs"`
}

Config is the struct for the config file

func LoadConfig

func LoadConfig(path string) (conf Config)

LoadConfig loads a yaml config file into a Config struct

type Job

type Job struct {
	Name     string       `yaml:"name"`
	Scheme   string       `yaml:"scheme"`
	URL      string       `yaml:"url"`
	Interval int          `yaml:"interval"`
	Timeout  int          `yaml:"timeout"`
	Headers  []JobHeaders `yaml:"headers"`
	Method   string       `yaml:"method"`
	Expect   JobExpect    `yaml:"expect"`
}

Job is the struct for a job in the config file

type JobExpect

type JobExpect struct {
	Status   int      `yaml:"status"`
	Body     string   `yaml:"body"`
	Contains []string `yaml:"contains"`
}

JobExpect is the struct for the expect in a job

type JobHeaders

type JobHeaders struct {
	Key   string `yaml:"key"`
	Value string `yaml:"value"`
}

JobHeaders is the struct for the headers in a job

type UpdateMetricPost

type UpdateMetricPost struct {
	URL          string  `json:"url"`
	Reason       string  `json:"reason"`
	ResCode      int     `json:"resCode"`
	MarkUp       bool    `json:"markUp"`
	ResponseTime float64 `json:"responseTime"`
}

UpdateMetricPost is the struct for the callback

Jump to

Keyboard shortcuts

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