package com.lutao.cloud.iot.mqtt.spring.server;

import io.micrometer.core.instrument.binder.MeterBinder;
import com.lutao.cloud.iot.mqtt.core.server.MqttServer;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


/**
 * mica mqtt Metrics 配置
 *

 */
@Configuration(proxyBeanMethods = false)
@ConditionalOnProperty(
	prefix = MqttServerProperties.PREFIX,
	name = "enabled",
	havingValue = "true",
	matchIfMissing = true
)
@ConditionalOnClass(MeterBinder.class)
@AutoConfigureAfter(MqttServerConfiguration.class)
public class MqttServerMetricsConfiguration {

	@Bean
	public MqttServerMetrics micaMqttMetrics(MqttServer mqttServer) {
		return new MqttServerMetrics(mqttServer.getServerConfig());
	}

}
