Search in sources :

Example 1 with HttpProvider

use of io.gravitee.management.services.dynamicproperties.provider.http.HttpProvider in project gravitee-management-rest-api by gravitee-io.

the class DynamicPropertiesService method startDynamicProperties.

private void startDynamicProperties(ApiEntity api) {
    if (api.getState() == Lifecycle.State.STARTED) {
        DynamicPropertyService dynamicPropertyService = api.getServices().get(DynamicPropertyService.class);
        if (dynamicPropertyService != null && dynamicPropertyService.isEnabled()) {
            DynamicPropertyUpdater updater = new DynamicPropertyUpdater(api);
            if (dynamicPropertyService.getProvider() == DynamicPropertyProvider.HTTP) {
                HttpProvider provider = new HttpProvider(dynamicPropertyService);
                provider.setVertx(vertx);
                updater.setProvider(provider);
                updater.setApiService(apiService);
                logger.info("Add a scheduled task to poll dynamic properties each {} {} ", dynamicPropertyService.getTrigger().getRate(), dynamicPropertyService.getTrigger().getUnit());
                // Force the first refresh, and then run it periodically
                updater.handle(null);
                long periodicTimer = vertx.setPeriodic(getDelayMillis(dynamicPropertyService.getTrigger()), updater);
                timers.put(api, periodicTimer);
            }
        } else {
            logger.info("Dynamic properties service is disabled for: {} [{}]", api.getName(), api.getVersion());
        }
    }
}
Also used : DynamicPropertyService(io.gravitee.definition.model.services.dynamicproperty.DynamicPropertyService) HttpProvider(io.gravitee.management.services.dynamicproperties.provider.http.HttpProvider)

Aggregations

DynamicPropertyService (io.gravitee.definition.model.services.dynamicproperty.DynamicPropertyService)1 HttpProvider (io.gravitee.management.services.dynamicproperties.provider.http.HttpProvider)1