diff --git a/pkg/pattern/ring_client.go b/pkg/pattern/ring_client.go index d1421b842422f..0d49cfe42379e 100644 --- a/pkg/pattern/ring_client.go +++ b/pkg/pattern/ring_client.go @@ -90,56 +90,30 @@ func (r *ringClient) Pool() *ring_client.Pool { return r.pool } -// StartAsync starts Service asynchronously. Service must be in New State, otherwise error is returned. -// Context is used as a parent context for service own context. func (r *ringClient) StartAsync(ctx context.Context) error { - return r.StartAsync(ctx) + return r.ring.StartAsync(ctx) } -// AwaitRunning waits until service gets into Running state. -// If service is in New or Starting state, this method is blocking. -// If service is already in Running state, returns immediately with no error. -// If service is in a state, from which it cannot get into Running state, error is returned immediately. func (r *ringClient) AwaitRunning(ctx context.Context) error { - return r.AwaitRunning(ctx) + return r.ring.AwaitRunning(ctx) } -// StopAsync tell the service to stop. This method doesn't block and can be called multiple times. -// If Service is New, it is Terminated without having been started nor stopped. -// If Service is in Starting or Running state, this initiates shutdown and returns immediately. -// If Service has already been stopped, this method returns immediately, without taking action. func (r *ringClient) StopAsync() { - r.StopAsync() + r.ring.StopAsync() } -// AwaitTerminated waits for the service to reach Terminated or Failed state. If service is already in one of these states, -// when method is called, method returns immediately. -// If service enters Terminated state, this method returns nil. -// If service enters Failed state, or context is finished before reaching Terminated or Failed, error is returned. func (r *ringClient) AwaitTerminated(ctx context.Context) error { - return r.AwaitTerminated(ctx) + return r.ring.AwaitTerminated(ctx) } -// FailureCase returns error if Service is in Failed state. -// If Service is not in Failed state, this method returns nil. func (r *ringClient) FailureCase() error { - return r.FailureCase() + return r.ring.FailureCase() } -// State returns current state of the service. func (r *ringClient) State() services.State { - return r.State() + return r.ring.State() } -// AddListener adds listener to this service. Listener will be notified on subsequent state transitions -// of the service. Previous state transitions are not replayed, so it is suggested to add listeners before -// service is started. -// -// AddListener guarantees execution ordering across calls to a given listener but not across calls to -// multiple listeners. Specifically, a given listener will have its callbacks invoked in the same order -// as the service enters those states. Additionally, at most one of the listener's callbacks will execute -// at once. However, multiple listeners' callbacks may execute concurrently, and listeners may execute -// in an order different from the one in which they were registered. func (r *ringClient) AddListener(listener services.Listener) { - r.AddListener(listener) + r.ring.AddListener(listener) }