Documentation ¶
Index ¶
- Constants
- func CheckHealthStatus(r *model.Registry) (model.HealthStatus, error)
- type DefaultManager
- func (m *DefaultManager) Add(registry *model.Registry) (int64, error)
- func (m *DefaultManager) Get(id int64) (*model.Registry, error)
- func (m *DefaultManager) GetByName(name string) (*model.Registry, error)
- func (m *DefaultManager) HealthCheck() error
- func (m *DefaultManager) List(query ...*model.RegistryQuery) (int64, []*model.Registry, error)
- func (m *DefaultManager) Remove(id int64) error
- func (m *DefaultManager) Update(registry *model.Registry, props ...string) error
- type HealthChecker
- type Manager
Constants ¶
const MinInterval = time.Minute * 5
MinInterval defines the minimum interval to check registries' health status.
Variables ¶
This section is empty.
Functions ¶
func CheckHealthStatus ¶
func CheckHealthStatus(r *model.Registry) (model.HealthStatus, error)
CheckHealthStatus checks status of a given registry
Types ¶
type DefaultManager ¶
type DefaultManager struct{}
DefaultManager implement the Manager interface
func NewDefaultManager ¶
func NewDefaultManager() *DefaultManager
NewDefaultManager returns an instance of DefaultManger
func (*DefaultManager) Add ¶
func (m *DefaultManager) Add(registry *model.Registry) (int64, error)
Add adds a new registry
func (*DefaultManager) Get ¶
func (m *DefaultManager) Get(id int64) (*model.Registry, error)
Get gets a registry by id
func (*DefaultManager) GetByName ¶
func (m *DefaultManager) GetByName(name string) (*model.Registry, error)
GetByName gets a registry by its name
func (*DefaultManager) HealthCheck ¶
func (m *DefaultManager) HealthCheck() error
HealthCheck checks health status of every registries and update their status. It will check whether a registry is reachable and the credential is valid
func (*DefaultManager) List ¶
func (m *DefaultManager) List(query ...*model.RegistryQuery) (int64, []*model.Registry, error)
List lists registries according to query provided.
func (*DefaultManager) Remove ¶
func (m *DefaultManager) Remove(id int64) error
Remove deletes a registry
type HealthChecker ¶
type HealthChecker struct {
// contains filtered or unexported fields
}
HealthChecker is used to regularly check all registries' health status and update check result to database
func NewHealthChecker ¶
func NewHealthChecker(interval time.Duration, closing chan struct{}) *HealthChecker
NewHealthChecker creates a new health checker - interval specifies the time interval to perform health check for registries - closing is a channel to stop the health checker
func (*HealthChecker) Run ¶
func (c *HealthChecker) Run()
Run performs health check for all registries regularly
type Manager ¶
type Manager interface { // Add new registry Add(*model.Registry) (int64, error) // List registries, returns total count, registry list and error List(...*model.RegistryQuery) (int64, []*model.Registry, error) // Get the specified registry Get(int64) (*model.Registry, error) // GetByName gets registry by name GetByName(name string) (*model.Registry, error) // Update the registry, the "props" are the properties of registry // that need to be updated Update(registry *model.Registry, props ...string) error // Remove the registry with the specified ID Remove(int64) error // HealthCheck checks health status of all registries and update result in database HealthCheck() error }
Manager defines the methods that a target manager should implement