io.vertx.up.uca.web.limit.ApiFactor Maven / Gradle / Ivy
package io.vertx.up.uca.web.limit;
import io.vertx.up.runtime.ZeroMotor;
import io.vertx.up.eon.em.ServerType;
import io.vertx.up.verticle.ZeroApiAgent;
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
/**
* This factor could begin following:
* 1. Http Api Gateway
* 2. Rx/Http mode shared.
*/
public class ApiFactor implements Factor {
private static final Class>[] DEFAULT_AGENTS = new Class>[]{
ZeroApiAgent.class
};
private static final ConcurrentMap> INTERNALS
= new ConcurrentHashMap>() {
{
this.put(ServerType.API, ZeroApiAgent.class);
}
};
@Override
public ConcurrentMap> agents() {
/* 1.Find Agent for deploy **/
final ConcurrentMap> agents
= ZeroMotor.agents(ServerType.HTTP, DEFAULT_AGENTS, INTERNALS);
/* 2. Filter invalid agents. **/
final Set scanned = new HashSet<>(agents.keySet());
final Set keeped = INTERNALS.keySet();
scanned.removeAll(keeped);
scanned.forEach(agents::remove);
return agents;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy