All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.nafg.mergify.QueueRule.scala Maven / Gradle / Ivy

The newest version!
package io.github.nafg.mergify

import java.time.Duration

import io.github.nafg.mergify.CirceConfig.snakeCase

import io.circe.Encoder
import io.circe.generic.extras.semiauto.deriveConfiguredEncoder

case class QueueRule(name: String,
                     mergeConditions: Seq[Condition],
                     speculativeChecks: Option[Int] = None,
                     allowInplaceSpeculativeChecks: Option[Boolean] = None,
                     allowSpeculativeChecksInterruption: Option[Boolean] = None,
                     batchSize: Option[Int] = None,
                     checksTimeout: Option[Duration] = None)

object QueueRule {
  implicit val encodeDuration: Encoder[Duration] =
    Encoder.encodeString.contramap { d =>
      List(
        d.toDaysPart    -> "days",
        d.toHoursPart   -> "hours",
        d.toMinutesPart -> "minutes",
        d.toSecondsPart -> "seconds"
      )
        .filter(_._1 != 0)
        .map(_.productIterator.mkString(" "))
        .mkString(" ")
    }
  implicit val encodeQueueRule: Encoder[QueueRule] = deriveConfiguredEncoder
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy