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

com.sksamuel.elastic4s.Handler.scala Maven / Gradle / Ivy

package com.sksamuel.elastic4s

import com.fasterxml.jackson.module.scala.JavaTypeable
import org.slf4j.{Logger, LoggerFactory}

/**
  * A [[Handler]] is a typeclass used to create [[ElasticRequest]] instances
  * from elastic4s models, which are the sent to the elasticsearch
  * server, as well as returning a [[ResponseHandler]] which handles the
  * response from the server.
  *
  * @tparam T the type of the request object handled by this handler
  * @tparam U the type of the response object returned by this handler
  */
abstract class Handler[T, U: JavaTypeable] {

  protected val logger: Logger = LoggerFactory.getLogger(getClass.getName)

  protected val TaskRegex = """\{"task":"(.*):(.*)"\}""".r

  def responseHandler: ResponseHandler[U] = ResponseHandler.default[U]
  def build(t: T): ElasticRequest
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy