package com.sikey.wa04.business.infrastructure.configuration;

import io.nats.client.Connection;
import io.nats.client.Nats;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author: qin
 * @Date: 2025/3/18
 * @Description: nat
 */
@Slf4j
@Configuration
public class NatsConfiguration {

    @Resource
    private NatsConfig natsConfig;

    @Bean
    public Connection natsConnection() throws Exception {
        String addr = natsConfig.getAddr();
        log.info("Connecting to NATS server: {}", addr);
        return Nats.connect(addr);
    }

}
