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

main.app.cash.backfila.embedded.Backfila.kt Maven / Gradle / Ivy

Go to download

Backfila is a service that manages backfill state, calling into other services to do batched work.

The newest version!
package app.cash.backfila.embedded

import app.cash.backfila.client.Backfill
import app.cash.backfila.client.spi.parametersToBytes
import app.cash.backfila.protos.service.ConfigureServiceRequest
import kotlin.reflect.KClass
import okio.ByteString

/**
 * Programmatic access to backfila UI features. This is useful in tests and development; in
 * production use the Backfila dashboard UI.
 * Java customers should use [JavaBackfila].
 */
interface Backfila {
  fun  createDryRun(
    backfill: KClass,
    parameters: Map,
    rangeStart: String?,
    rangeEnd: String?,
  ): BackfillRun

  fun  createWetRun(
    backfillType: KClass,
    parameters: Map,
    rangeStart: String?,
    rangeEnd: String?,
  ): BackfillRun

  fun  findExistingRun(
    backfillType: KClass,
    backfillRunId: Long,
  ): BackfillRun

  fun  findLatestRun(
    backfillType: KClass,
  ): BackfillRun

  val configureServiceData: ConfigureServiceRequest?
}

inline fun  Backfila.createDryRun(
  parameters: Any? = null,
  parameterData: Map = mapOf(),
  rangeStart: String? = null,
  rangeEnd: String? = null,
): BackfillRun {
  return createDryRun(Type::class, parameters, parameterData, rangeStart, rangeEnd)
}

fun  Backfila.createDryRun(
  backfill: KClass,
  parameters: Any?,
  parameterData: Map,
  rangeStart: String?,
  rangeEnd: String?,
): BackfillRun {
  check(parameterData.isEmpty() || parameters == null) {
    "Only one of parameters and parameterData can be set"
  }
  val parameterBytes =
    if (parameters != null) {
      parametersToBytes(parameters)
    } else {
      parameterData
    }
  return createDryRun(backfill, parameterBytes, rangeStart, rangeEnd)
}

inline fun  Backfila.createWetRun(
  parameters: Any? = null,
  parameterData: Map = mapOf(),
  rangeStart: String? = null,
  rangeEnd: String? = null,
): BackfillRun {
  return createWetRun(Type::class, parameters, parameterData, rangeStart, rangeEnd)
}

fun  Backfila.createWetRun(
  backfill: KClass,
  parameters: Any?,
  parameterData: Map,
  rangeStart: String?,
  rangeEnd: String?,
): BackfillRun {
  check(parameterData.isEmpty() || parameters == null) {
    "Only one of parameters and parameterData can be set"
  }
  val parameterBytes =
    if (parameters != null) {
      parametersToBytes(parameters)
    } else {
      parameterData
    }
  return createWetRun(backfill, parameterBytes, rangeStart, rangeEnd)
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy