package com.brilliance.isc.counter.config;

import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
@Data
public class SegmentConfig{

    @Value("${counter.segment.buffLen:10}")
    private int buffLen;

    @Value("${counter.segment.enabled:true}")
    private boolean enabled;

    @Value("${counter.segment.enableRegexp:.*}")
    private String enableRegexp;

    @Value("${counter.segment.buffUpdTimeout:2}")
    private int buffUpdTimeout;

    public boolean segmentAllowed(String key){
        return enabled && key.matches(enableRegexp);
    }

}
