package com.tsi.comm.server.config;

import com.tsi.common.utils.TimeUtils;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

@Slf4j
@Getter
@Setter
@ToString
@Component
@ConfigurationProperties(prefix = "application")
public class ApplicationConfig {

    private String processId = "tsi-comm-server";
    private double cpuLimits = 75;
    private String bootingTime;
    private boolean startSchedule;

    @PostConstruct
    private void init() {
        this.startSchedule = false;
        this.bootingTime = TimeUtils.now();

        if (this.cpuLimits < 50) this.cpuLimits = 50;
        if (this.cpuLimits > 90) this.cpuLimits = 90;

        log.info("[ApplicationConfig] -------------------------");
        log.info("[ApplicationConfig]         processId: {}", this.processId);
        log.info("[ApplicationConfig]         cpuLimits: {}", this.cpuLimits);
    }

}
