func NewServer(config Config) (_ *Server, err error) {
	defer derrors.Wrap(&err, "NewServer")
	b, err := breaker.New(config.BreakerConfig)
	if err != nil {
		return nil, err
	}
	return &Server{
		limiter: rate.NewLimiter(rate.Limit(config.Rate), config.Burst),
		breaker: b,
	}, nil
}
// NewServer returns a new Server struct with preconfigured settings.
//
// The server is rate limited and allows events up to a rate of "Rate" and
// a burst of "Burst".
//
// The server also implements the circuit breaker pattern and can be in one of
// three states: green, yellow, or red.
//
// In the green state, the server remains green until it encounters an time
// window of length "GreenInterval" where there are more than of "FailsToRed"
// failures and a failureRatio of more than "FailureThreshold", in which case
// the state becomes red.
//
// In the red state, the server halts all requests and waits for a timeout
// period before shifting to the yellow state.
//
// In the yellow state, the server allows the first "SuccsToGreen" requests.
// If any of these fail, the state reverts to red.
// Otherwise, the state becomes green again.
//
// The timeout period is initially set to "MinTimeout" when the breaker shifts
// from green to yellow. By default, the timeout period is doubled each time
// the breaker fails to shift from the yellow state to the green state and is
// capped at "MaxTimeout".
NewServer returns a new Server struct with preconfigured settings.

The server is rate limited and allows events up to a rate of "Rate" and
a burst of "Burst".

The server also implements the circuit breaker pattern and can be in one of
three states: green, yellow, or red.

In the green state, the server remains green until it encounters an time
window of length "GreenInterval" where there are more than of "FailsToRed"
failures and a failureRatio of more than "FailureThreshold", in which case
the state becomes red.

In the red state, the server halts all requests and waits for a timeout
period before shifting to the yellow state.

In the yellow state, the server allows the first "SuccsToGreen" requests.
If any of these fail, the state reverts to red.
Otherwise, the state becomes green again.

The timeout period is initially set to "MinTimeout" when the breaker shifts
from green to yellow. By default, the timeout period is doubled each time
the breaker fails to shift from the yellow state to the green state and is
capped at "MaxTimeout".
// NewServer returns a new Server struct with preconfigured settings . // // The server is rate limited and allows events up to a rate of " Rate " and // a burst of " Burst " . // // The server also implements the circuit breaker pattern and can be in one of // three states : green yellow or red . // // In the green state the server remains green until it encounters an time // window of length " GreenInterval " where there are more than of " FailsToRed " // failures and a failureRatio of more than " FailureThreshold " in which case // the state becomes red . // // In the red state the server halts all requests and waits for a timeout // period before shifting to the yellow state . // // In the yellow state the server allows the first " SuccsToGreen " requests . // If any of these fail the state reverts to red . // Otherwise the state becomes green again . // // The timeout period is initially set to " MinTimeout " when the breaker shifts // from green to yellow . By default the timeout period is doubled each time // the breaker fails to shift from the yellow state to the green state and is // capped at " MaxTimeout " .
func NewServer(config Config) (_ *Server, err error) {
	defer derrors.Wrap(&err, "NewServer")
	b, err := breaker.New(config.BreakerConfig)
	if err != nil {
		return nil, err
	}
	return &Server{
		limiter: rate.NewLimiter(rate.Limit(config.Rate), config.Burst),
		breaker: b,
	}, nil
}
func NewServer ( config Config ) ( _ * Server , err error ) { defer derrors . Wrap ( & err , " " ) b , err := breaker . New ( config . BreakerConfig ) if err != nil { return nil , err } return & Server { limiter : rate . NewLimiter ( rate . Limit ( config . Rate ) , config . Burst ) , breaker : b , } , nil }
NewServer returns a new Server struct with preconfigured settings.
NewServer returns a new Server struct with preconfigured settings .