spring:
  application:
    name: event-service

  # Database Configuration (PostgreSQL)
  datasource:
    url: jdbc:postgresql://${DB_HOST:20.249.177.232}:${DB_PORT:5432}/${DB_NAME:eventdb}
    username: ${DB_USERNAME:eventuser}
    password: ${DB_PASSWORD:Hi5Jessica!}
    driver-class-name: org.postgresql.Driver
    hikari:
      maximum-pool-size: 5
      minimum-idle: 2
      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: false
        show_sql: false
        use_sql_comments: false
        jdbc:
          batch_size: 20
          time_zone: Asia/Seoul
    open-in-view: false

  # Redis Configuration
  data:
    redis:
      host: ${REDIS_HOST:20.214.210.71}
      port: ${REDIS_PORT:6379}
      password: ${REDIS_PASSWORD:Hi5Jessica!}
      database: ${REDIS_DATABASE:0}
      timeout: 60000ms
      connect-timeout: 60000ms
      lettuce:
        pool:
          max-active: 5
          max-idle: 3
          min-idle: 1
          max-wait: -1ms
        shutdown-timeout: 200ms

  # Kafka Configuration
  kafka:
    bootstrap-servers: ${KAFKA_BOOTSTRAP_SERVERS:20.249.182.13:9095,4.217.131.59:9095}
    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: /api/v1
  shutdown: graceful

# Actuator Configuration
management:
  endpoints:
    web:
      exposure:
        include: health,info,metrics,prometheus
      base-path: /actuator
  endpoint:
    health:
      show-details: always
      show-components: always
  health:
    redis:
      enabled: false
    livenessState:
      enabled: true
    readinessState:
      enabled: true

# Logging Configuration
logging:
  level:
    root: INFO
    com.kt.event: ${LOG_LEVEL:INFO}
    org.springframework: WARN
    org.springframework.data.redis: WARN
    io.lettuce.core: WARN
    org.hibernate.SQL: ${SQL_LOG_LEVEL:WARN}
    org.hibernate.type.descriptor.sql.BasicBinder: WARN
  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"
  file:
    name: ${LOG_FILE:logs/event-service.log}
  logback:
    rollingpolicy:
      max-file-size: 10MB
      max-history: 7
      total-size-cap: 100MB

# 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

  # Content Service Client
  content-service:
    url: ${CONTENT_SERVICE_URL:http://localhost:8084}

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

# 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분 (밀리초 단위)

# JWT Configuration
jwt:
  secret: ${JWT_SECRET:default-jwt-secret-key-for-development-minimum-32-bytes-required}
  expiration: 86400000  # 24시간 (밀리초 단위)

# CORS Configuration
cors:
  allowed-origins: ${CORS_ALLOWED_ORIGINS:http://localhost:8081,http://localhost:8082,http://localhost:8083,http://localhost:8084,http://kt-event-marketing.20.214.196.128.nip.io}
  allowed-methods: ${CORS_ALLOWED_METHODS:GET,POST,PUT,DELETE,OPTIONS,PATCH}
  allowed-headers: ${CORS_ALLOWED_HEADERS:*}
  allow-credentials: ${CORS_ALLOW_CREDENTIALS:true}
  max-age: ${CORS_MAX_AGE:3600}
