Example #1
0
	// HealthRetryTimeSec determines how long to wait between retries when a health check
	// fails to write.
	HealthRetryTimeSec = param.Int("health_retry_time_sec", 5)

	// SessionTTLSec sets the TTL time for each session created by consulHealthManager. This
	// parameter controls how long it takes for clients to notice that health checks have
	// stopped.
	SessionTTLSec = param.Int("health_session_ttl_sec", 15)

	// HealthWritesPerMinute sets the average number of writes per minute per service that
	// will be sent to Consul to update health.
	HealthWritesPerMinute = param.Int("health_writes_per_minute", 4)

	// HealthMaxBucketSize sets the maximum token bucket size per service used to
	// rate-limit Consul writes.
	HealthMaxBucketSize = param.Int64("health_max_bucket_size", 16)

	// HealthResumeLimit sets the lower bound on the number of tokens at which updates will
	// be resumed. If a service runs out of tokens, its last update will be to set the
	// health status to "unknown" with an error message, and further updates will be
	// throttled until enough tokens have been accumulated.
	HealthResumeLimit = param.Int64("health_resume_limit", 4)
)

// consulHealthManager maintains a Consul session for all the local node's health checks,
// renews it periodically, and refreshes all health checks if it expires.
type consulHealthManager struct {
	sessionPub *stream.StringValuePublisher // Publishes the current session
	done       chan struct{}                // Close this to stop reporting health
	client     consulutil.ConsulClient      // Connection to the Consul agent
	node       types.NodeName
Example #2
0
File: health.go Project: rudle/p2
	"github.com/square/p2/pkg/kp"
	"github.com/square/p2/pkg/logging"
	"github.com/square/p2/pkg/manifest"
	"github.com/square/p2/pkg/preparer"
	"github.com/square/p2/pkg/types"
	"github.com/square/p2/pkg/util/param"
)

// These constants should probably all be something the p2 user can set
// in their preparer config...

// Duration between health checks
const HEALTHCHECK_INTERVAL = 1 * time.Second

// Maximum allowed time for a single check, in seconds
var HEALTHCHECK_TIMEOUT = param.Int64("healthcheck_timeout", 5)

// Contains method for watching the consul reality store to
// track services running on a node. A manager method:
// MonitorPodHealth tracks the reality store and manages
// a health checking go routine for each service in the
// reality store

// PodWatch houses a pod's manifest, a channel to kill the
// pod's goroutine if the pod is removed from the reality
// tree, and a bool that indicates whether or not the pod
// has a running MonitorHealth go routine
type PodWatch struct {
	manifest      manifest.Manifest
	updater       kp.HealthUpdater
	statusChecker StatusChecker