Class

io.epiphanous.flinkrunner.operator

EnrichmentAsyncFunction

Related Doc: package operator

Permalink

abstract class EnrichmentAsyncFunction[IN, OUT, CV <: AnyRef] extends AsyncFunction[IN, OUT] with LazyLogging

An abstract asynchronous function to enrich a data stream with non-stream data. This class relies on guava's CacheBuilder to load and cache the enrichment data. The default cache loader assumes the cache key is a uri of a json api endpoint which it loads asynchronously and converts to the cache value type (CV). You can provide your own cache loader to load enrichment data in some other way. If you use the default loader, note you must implicitly provide a circe EntityDecoder to convert the json api result body to the cache value type.

The behavior of the function can be parameterized with flink config values for

The cache always uses weak keys, allowing for aggressive garbage collection of unused values.

Subclasses must implement the getCacheKey() and enrichEvent() methods.

IN

the input stream element type

OUT

the enriched stream output element type

CV

the cache value type

Linear Supertypes
LazyLogging, AsyncFunction[IN, OUT], Function, Serializable, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. EnrichmentAsyncFunction
  2. LazyLogging
  3. AsyncFunction
  4. Function
  5. Serializable
  6. AnyRef
  7. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new EnrichmentAsyncFunction(configPrefix: String, cacheLoaderOpt: Option[CacheLoader[String, Option[CV]]] = None, preloaded: Map[String, CV] = Map.empty[String, CV])(implicit config: FlinkConfig, decoder: Decoder[CV])

    Permalink

    configPrefix

    for extracting configuration information

    cacheLoaderOpt

    an optional CacheLoader for loading the enrichment data

    config

    implicit flink config

    decoder

    implicit entity decoder for converting the body of the api call to the cache value type

Abstract Value Members

  1. abstract def enrichEvent(in: IN, data: Option[CV]): Seq[OUT]

    Permalink

    Construct a sequence of zero or more enriched output events using the input event and the api results.

    Construct a sequence of zero or more enriched output events using the input event and the api results.

    in

    input event

    data

    some api results (or none if api call failed)

  2. abstract def getCacheKey(in: IN): String

    Permalink

    Generate the cache key from the input event.

    Generate the cache key from the input event. For the default cache loader implementation, this should be a json api endpoint uri. If you provide your own cache loader implementation, this should be whatever is appropriate, however, it must be a String.

    in

    the input event

Concrete Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. lazy val api: Resource[IO, Client[IO]]

    Permalink
  5. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  6. def asyncInvoke(in: IN, collector: ResultFuture[OUT]): Unit

    Permalink
    Definition Classes
    EnrichmentAsyncFunction → AsyncFunction
  7. def asyncInvokeF(in: IN): Future[Try[Seq[OUT]]]

    Permalink

    A helper method to enable testing of asyncInvoke() without needing to construct a flink ResultFuture collector.

    A helper method to enable testing of asyncInvoke() without needing to construct a flink ResultFuture collector.

    in

    the input event

  8. lazy val cache: LoadingCache[String, Option[CV]]

    Permalink
  9. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  10. implicit lazy val cs: ContextShift[IO]

    Permalink
  11. lazy val defaultCacheLoader: CacheLoader[String, Option[CV]]

    Permalink

    The default cache loader implementation.

    The default cache loader implementation. This uses a blaze client to make an api call and converts the result to the cache value type (CV). This loader will be used unless one is passed into the class constructor (usually just done for testing).

  12. implicit lazy val ec: ExecutionContext

    Permalink

    A thread pool execution context for making asynchronous api calls.

  13. implicit lazy val entityDecoder: EntityDecoder[IO, CV]

    Permalink
  14. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  15. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  16. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  17. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  18. def getConfigPrefix: String

    Permalink

    Getter for $configPrefix value

  19. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  20. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  21. lazy val logger: Logger

    Permalink
    Attributes
    protected
    Definition Classes
    LazyLogging
  22. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  23. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  24. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  25. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  26. def timeout(input: IN, resultFuture: ResultFuture[OUT]): Unit

    Permalink
    Definition Classes
    AsyncFunction
  27. implicit lazy val timer: Timer[IO]

    Permalink
  28. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  29. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  30. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  31. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from LazyLogging

Inherited from AsyncFunction[IN, OUT]

Inherited from Function

Inherited from Serializable

Inherited from AnyRef

Inherited from Any

Ungrouped