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

com.github.lontime.extredisson.service.DelayedConsumerProcessor Maven / Gradle / Ivy

There is a newer version: 1.4.0
Show newest version
package com.github.lontime.extredisson.service;

import java.time.Duration;

import com.github.lontime.base.commonj.components.DelayedProcessor;
import com.github.lontime.base.commonj.utils.LoggerHelper;
import com.github.lontime.extredisson.configuration.ConsumerOption;

/**
 * DelayedConsumerProcessor.
 * @author lontime
 * @since 1.0
 */
public class DelayedConsumerProcessor extends DelayedProcessor {

    private final ConsumerOption consumerOptions;

    private DefaultStreamService service;

    public DelayedConsumerProcessor(ConsumerOption consumerOptions) {
        this.consumerOptions = consumerOptions;
        this.service = new DefaultStreamService(consumerOptions);
    }

    @Override
    protected Duration sleepTimeout() {
        return consumerOptions.getInterval();
    }

    @Override
    protected Duration initialDelay() {
        return consumerOptions.getWarmup();
    }

    @Override
    protected void startUp() {
        LoggerHelper.info(getClass(), "startUp state {0}", currentState());
        if (service != null) {
            service.initialize();
        }
    }

    @Override
    public boolean doLoop() {
        if (service != null) {
            return service.doLoop();
        }
        return false;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy