Skip to content

CleverCloud/warp10-scala-client

Repository files navigation

Tests

Central Version

Scala client for Warp10 Geo/time series DB.

Documentation

Scaladoc is available here.

// to generate documentation on gh-pages branch
sbt ghpagesPushSite

Use it

Add the library dependency:

"com.clever-cloud" %% "warp10-scala-client" % "<version>"

Configuration

import scala.concurrent.ExecutionContext

import org.apache.pekko
import pekko.actor._
import pekko.stream.Materializer

import com.clevercloud.warp10client._
import com.clevercloud.warp10client.models._
import com.clevercloud.warp10client.models.gts_module._

given executionContext: ExecutionContext = system.dispatchers.lookup("yourContext")
given warpConfiguration: WarpConfiguration = WarpConfiguration("www.clever-cloud.com")
val warpClient = Warp10Client("clever-cloud.com", 80)

Classical usage

val labels = Map(
  "exactLabel=" -> "label1",
  "regexLabel~" -> "lab.*"
)

warpClient.fetch(
  "READ_TOKEN",
  Query(
    Selector("warpClass", labels),
    FetchRange(LocalDateTime.now.minusSeconds(100), LocalDateTime.now)
  )
).map { gts =>
  ...
}

warpClient.exec(s"""
  1 h 'duration' STORE
  NOW 'now' STORE
  [ '${token.token}' '~alert.http.status' { 'owner_id' '561bf859-b1ae-41bd-bd89-3421fbad0697' } $$now $$duration ] FETCH
  [ 0 1 ]
  SUBLIST
""").map { gtsList =>
  ...
}

warpClient.push(gts: GTS, "WRITE_TOKEN")
// or
warpClient.push(gts: Seq[GTS], "WRITE_TOKEN", batchSize = 300)

Pekko Streams usage

Flow[Query[FetchRange]]
  .map { gtsSequence =>
    ...
  }

Flow[WarpScript]
  .map { gtsSequence =>
    ...
  }

Flow[GTS]
  .via(warpClient.push("WRITE_TOKEN"))

Have a look at the test directory for functional tests and code examples

About

Warp10 Scala client which is using Pekko HTTP or Streams.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages