func (b *FusisBalancer) AddCheck(check types.CheckSpec) error { // Setting default values if check.Timeout == 0 { check.Timeout = 5 * time.Second } if check.Interval == 0 { check.Interval = 10 * time.Second } return b.store.AddCheck(check) }
func (as ApiService) addCheck(c echo.Context) error { var check types.CheckSpec if err := c.Bind(&check); err != nil { return err } check.ServiceID = c.Param("service_name") // Converting int to time.Duration check.Interval = check.Interval * time.Second check.Timeout = check.Timeout * time.Second if err := as.balancer.AddCheck(check); err != nil { return err } return c.JSON(http.StatusCreated, check) }