All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.netflix.eureka2.client.channel.RegistrationChannelInvoker Maven / Gradle / Ivy

package com.netflix.eureka2.client.channel;

import com.netflix.eureka2.registry.InstanceInfo;
import com.netflix.eureka2.service.RegistrationChannel;
import com.netflix.eureka2.utils.SerializedTaskInvoker;
import rx.Observable;

import java.util.concurrent.Callable;

/**
 * A decorator of {@link RegistrationChannel} which delegates to an actual {@link RegistrationChannel} making sure that
 * all operations on the underlying channel are strictly sequenced in the order they arrive on this channel.
 *
 * @author Nitesh Kant
 */
/*pkg-private: Used by EurekaClientService only*/class RegistrationChannelInvoker
        extends SerializedTaskInvoker implements RegistrationChannel {

    private final RegistrationChannel delegate;

    public RegistrationChannelInvoker(RegistrationChannel delegate) {
        this.delegate = delegate;
    }

    @Override
    public Observable register(final InstanceInfo instanceInfo) {
        return submitForAck(new Callable>() {
            @Override
            public Observable call() throws Exception {
                return delegate.register(instanceInfo);
            }
        });
    }

    @Override
    public Observable update(final InstanceInfo newInfo) {
        return submitForAck(new Callable>() {
            @Override
            public Observable call() throws Exception {
                return delegate.update(newInfo);
            }
        });
    }

    @Override
    public Observable unregister() {
        return submitForAck(new Callable>() {
            @Override
            public Observable call() throws Exception {
                return delegate.unregister();
            }
        });
    }

    @Override
    public void close() {
        try {
            shutdown();
        } finally {
            delegate.close();
        }
    }

    @Override
    public Observable asLifecycleObservable() {
        return delegate.asLifecycleObservable();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy