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

io.vertx.up.uca.monitor.meansure.AbstractQuota Maven / Gradle / Ivy

There is a newer version: 0.9.0
Show newest version
package io.vertx.up.uca.monitor.meansure;

import io.vertx.core.Vertx;
import io.vertx.core.shareddata.AsyncMap;

import java.util.Objects;
import java.util.function.Consumer;

/**
 * @author Lang
 */
public abstract class AbstractQuota implements Quota {
    protected final transient Vertx vertx;

    public AbstractQuota(final Vertx vertx) {
        this.vertx = vertx;
    }

    protected void mapAsync(final String name, final Consumer> consumer) {
        this.vertx.sharedData().getAsyncMap(name, mapped -> {
            if (mapped.succeeded()) {
                consumer.accept(mapped.result());
            } else {
                if (Objects.nonNull(mapped.cause())) {
                    mapped.cause().printStackTrace();
                }
            }
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy