package com.tax.token.job;

import com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.api.simple.SimpleJob;
import com.google.common.base.Stopwatch;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.concurrent.TimeUnit;

/**
 * @author caosongqing
 * @date 2022/7/28
 * @description
 */
@Slf4j
@Component
public class MonitorTokenJob implements SimpleJob {

    @Autowired
    private SynGetTokenTask synGetTokenTask;

    @Override
    public void execute(ShardingContext shardingContext) {
        Stopwatch stopwatch = Stopwatch.createStarted();
        int count = synGetTokenTask.countToken();
        stopwatch.stop();
        log.info("monitor token count:{} elapsed: {} ms", count, stopwatch.elapsed(TimeUnit.MILLISECONDS));
    }
}
