datasourcex-java-flow

Provides an API for binding implementations of Java's Flow to subjects and channels provided by Caplin DataSource.
This library is designed for use from both Java and Kotlin.

Alternative Implementation

For most projects it is recommended to use the datasourcex-reactivestreams module instead, as it provides better compatibility with reactive libraries such as RxJava, Reactor & Akka Streams.

See also

Samples

Bind.using(dataSource) {
  to("my-service") {
    active {
      record {
        path(
            path = "/example/activeSubject",
            publisher =
                FlowAdapters.toFlowPublisher(
                    Flux.interval(Duration.ofSeconds(1)).map { aLong: Long ->
                      mapOf("Count" to aLong.toString())
                    }
                ),
        ) {
          recordType = RecordType.TYPE1
        }
      }

      json {
        pattern(
            pattern = "/example/{username}/subjectPattern/{myKey}",
            configure = { objectMappings = mapOf("username" to "%u") },
            supplier = { _, parameters ->
              val username = parameters["username"]
              val myKey = parameters["myKey"]
              FlowAdapters.toFlowPublisher(
                  Flux.interval(Duration.ofSeconds(1)).map { count: Long ->
                    JsonObject("$username $myKey $count")
                  }
              )
            },
        )
      }
    }
  }
}

Packages