
org.nameapi.client.services.system.ping.PingCommand Maven / Gradle / Ivy
package org.nameapi.client.services.system.ping;
import com.google.common.base.Optional;
import com.optimaize.command4j.ExecutionContext;
import org.jetbrains.annotations.NotNull;
import org.nameapi.client.services.NameApiBaseCommand;
import java.util.concurrent.Callable;
/**
* The ping command simply pings the server and, on success, gets a "pong" back.
*
* Ping can be used either manually or by code to check for service availability and response time.
*
* The command passes through all interceptors (authentication, load balancing etc.) to a target server
* that actually executes nameapi requests. All standard behavior applies including request
* prioritization and request limits per contract. The only difference is that the minimal response time
* used on free accounts is not applied.
*
* @author eike, andrej
*/
public class PingCommand extends NameApiBaseCommand {
private static final String SERVICE_PATH = "/system/ping";
public PingCommand() {
super(RestPort.class);
}
@Override
public String call(@NotNull Optional arg, @NotNull ExecutionContext ec) throws Exception {
return getPort(ec).ping(getApiKey(ec));
}
@NotNull @Override
protected Callable createPort(@NotNull final ExecutionContext ec) {
return new Callable() {
@Override
public RestPort call() throws Exception {
return new RestPort(makeClient(ec), SERVICE_PATH);
}
};
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy