spring:
  application:
    name: event-service

  # Database Configuration (PostgreSQL)
  datasource:
    url: jdbc:postgresql://${DB_HOST:localhost}:${DB_PORT:5432}/${DB_NAME:eventdb}
    username: ${DB_USERNAME:eventuser}
    password: ${DB_PASSWORD:eventpass}
    driver-class-name: org.postgresql.Driver
    hikari:
      maximum-pool-size: 10
      minimum-idle: 5
      connection-timeout: 30000
      idle-timeout: 600000
      max-lifetime: 1800000

  # JPA Configuration
  jpa:
    database-platform: org.hibernate.dialect.PostgreSQLDialect
    hibernate:
      ddl-auto: ${DDL_AUTO:update}
    properties:
      hibernate:
        format_sql: true
        show_sql: false
        use_sql_comments: true
        jdbc:
          batch_size: 20
          time_zone: Asia/Seoul
    open-in-view: false

  # Redis Configuration
  data:
    redis:
      host: ${REDIS_HOST:localhost}
      port: ${REDIS_PORT:6379}
      password: ${REDIS_PASSWORD:}
      lettuce:
        pool:
          max-active: 10
          max-idle: 5
          min-idle: 2

  # Kafka Configuration
  kafka:
    bootstrap-servers: ${KAFKA_BOOTSTRAP_SERVERS:localhost:9092}
    producer:
      key-serializer: org.apache.kafka.common.serialization.StringSerializer
      value-serializer: org.springframework.kafka.support.serializer.JsonSerializer
      properties:
        spring.json.add.type.headers: false
    consumer:
      group-id: event-service-consumers
      key-deserializer: org.apache.kafka.common.serialization.StringDeserializer
      value-deserializer: org.springframework.kafka.support.serializer.JsonDeserializer
      properties:
        spring.json.trusted.packages: "*"
        spring.json.use.type.headers: false
      auto-offset-reset: earliest
      enable-auto-commit: false
    listener:
      ack-mode: manual

# Server Configuration
server:
  port: ${SERVER_PORT:8080}
  servlet:
    context-path: /
  shutdown: graceful

# Actuator Configuration
management:
  endpoints:
    web:
      exposure:
        include: health,info,metrics,prometheus
  endpoint:
    health:
      show-details: always
  health:
    redis:
      enabled: true
    db:
      enabled: true

# Logging Configuration
logging:
  level:
    root: INFO
    com.kt.event: ${LOG_LEVEL:DEBUG}
    org.springframework: INFO
    org.hibernate.SQL: ${SQL_LOG_LEVEL:DEBUG}
    org.hibernate.type.descriptor.sql.BasicBinder: TRACE
  pattern:
    console: "%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n"
    file: "%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n"

# Springdoc OpenAPI Configuration
springdoc:
  api-docs:
    path: /api-docs
  swagger-ui:
    path: /swagger-ui.html
    operations-sorter: method
    tags-sorter: alpha
  show-actuator: false

# Feign Client Configuration
feign:
  client:
    config:
      default:
        connectTimeout: 5000
        readTimeout: 10000
        loggerLevel: basic

  # Distribution Service Client
  distribution-service:
    url: ${DISTRIBUTION_SERVICE_URL:http://localhost:8084}

# Application Configuration
app:
  kafka:
    topics:
      ai-event-generation-job: ai-event-generation-job
      image-generation-job: image-generation-job
      event-created: event-created

  redis:
    ttl:
      ai-result: 86400  # 24시간 (초 단위)
      image-result: 604800  # 7일 (초 단위)
    key-prefix:
      ai-recommendation: "ai:recommendation:"
      image-generation: "image:generation:"
      job-status: "job:status:"

  job:
    timeout:
      ai-generation: 300000  # 5분 (밀리초 단위)
      image-generation: 300000  # 5분 (밀리초 단위)
