Search in sources :

Example 1 with RemoteInterface

use of rpc.turbo.remote.RemoteInterface in project turbo-rpc by hank-whu.

the class TurboClient method setFailover.

/**
 * 设置失败回退方法
 *
 * @param clazz
 * @param failover
 */
public <T> void setFailover(Class<T> clazz, Object failover) {
    Objects.requireNonNull(clazz, "clazz");
    T service = remoteServiceFactory.getService(clazz);
    if (service == null) {
        throw new RemoteException("not register this service, " + clazz.getName());
    }
    try {
        App app = ((RemoteInterface) service).getApp();
        remoteServiceFactory.setFailover(app, clazz, service, failover);
    } catch (Exception e) {
        throw new RemoteException(e);
    }
}
Also used : App(rpc.turbo.transport.client.App) RemoteInterface(rpc.turbo.remote.RemoteInterface) RemoteException(rpc.turbo.remote.RemoteException) IOException(java.io.IOException) RemoteException(rpc.turbo.remote.RemoteException)

Aggregations

IOException (java.io.IOException)1 RemoteException (rpc.turbo.remote.RemoteException)1 RemoteInterface (rpc.turbo.remote.RemoteInterface)1 App (rpc.turbo.transport.client.App)1