Skip to content
This repository was archived by the owner on Mar 15, 2022. It is now read-only.
This repository was archived by the owner on Mar 15, 2022. It is now read-only.

healthcheck function only executed once? #22

Description

Hi,
trying to get this little example to run but it does not seem to even execute the mycheck function more than once during the startup. I thought it should be happening every time I try to access the /live endpoint?

package main

import (
	"errors"
	"fmt"
	h "github.com/heptiolabs/healthcheck"
	"math/rand"
	"net/http"
)

func main() {
	Example()
}

func Example() {
	health := h.NewHandler()
	health.AddLivenessCheck("mycheck", mycheck())
	http.ListenAndServe("0.0.0.0:8080", health)
}

func mycheck() h.Check {
	if rand.Intn(2) == 1 {
		return func() error {
			return nil
		}
	} else {
		return func() error {
			return errors.New("0")
		}
	}
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions