Пример #1
0
func newWeights(weights ...int) []SuggestedWeight {
	out := make([]SuggestedWeight, len(weights))
	for i, w := range weights {
		out[i] = &EndpointWeight{
			Weight:   w,
			Endpoint: &WeightedEndpoint{endpoint: endpoint.MustParseUrl(fmt.Sprintf("http://localhost:500%d", i))},
		}
	}
	return out
}
Пример #2
0
func (s *FSMSuite) TestMetricsAreNotReady(c *C) {
	endpoints := []*WeightedEndpoint{
		&WeightedEndpoint{
			meter:           &metrics.TestMeter{Rate: 0.5, NotReady: true},
			endpoint:        endpoint.MustParseUrl("http://localhost:5000"),
			weight:          1,
			effectiveWeight: 1,
		},
		&WeightedEndpoint{
			meter:           &metrics.TestMeter{Rate: 0, NotReady: true},
			endpoint:        endpoint.MustParseUrl("http://localhost:5001"),
			weight:          1,
			effectiveWeight: 1,
		},
	}
	adjusted, err := s.newF(endpoints).AdjustWeights()
	c.Assert(err, IsNil)
	c.Assert(getWeights(adjusted), DeepEquals, []int{1, 1})
}
Пример #3
0
func newW(failRates ...float64) []*WeightedEndpoint {
	out := make([]*WeightedEndpoint, len(failRates))
	for i, r := range failRates {
		out[i] = &WeightedEndpoint{
			meter:           &metrics.TestMeter{Rate: r, WindowSize: time.Second * 10},
			endpoint:        endpoint.MustParseUrl(fmt.Sprintf("http://localhost:500%d", i)),
			weight:          1,
			effectiveWeight: 1,
		}
	}
	return out
}