Andrey Smirnov 1dde9f8cc0 feat(init): implement health checks for services (#656)
Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2019-05-15 09:30:35 -07:00

36 lines
1.3 KiB
Go

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package system
import (
"github.com/talos-systems/talos/internal/app/init/pkg/system/conditions"
"github.com/talos-systems/talos/internal/app/init/pkg/system/health"
"github.com/talos-systems/talos/internal/app/init/pkg/system/runner"
"github.com/talos-systems/talos/pkg/userdata"
)
// Service is an interface describing a system service.
type Service interface {
// ID is the service id.
ID(*userdata.UserData) string
// PreFunc is invoked before a runner is created
PreFunc(*userdata.UserData) error
// Runner creates runner for the service
Runner(*userdata.UserData) (runner.Runner, error)
// PostFunc is invoked after a runner is closed.
PostFunc(*userdata.UserData) error
// ConditionFunc describes the conditions under which a service should
// start.
ConditionFunc(*userdata.UserData) conditions.ConditionFunc
}
// HealthcheckedService is a service which provides health check
type HealthcheckedService interface {
// HealtFunc provides function that checks health of the service
HealthFunc(*userdata.UserData) health.Check
// HealthSettings returns settings for the health check
HealthSettings(*userdata.UserData) *health.Settings
}