Giter VIP home page Giter VIP logo

warp10-scala-client's Introduction

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.