streams-story Pub

Stream tests

Create a named stream. It will be owned by this flow...

val total:Number=0=0 send::  msg diesel.stream.new  (stream="s1"="s1")

Start a generator in same flow send::  msg testdiesel.streams.startGenerator  (stream="s1"="s1", howMany:Number=3=3)

send::  msg diesel.stream.consume  (stream="s1"="s1", xtimeout:Number=1000=1000)

expect::  (total is 15)

Batch processing: putAll and onDataSlice

send::  msg diesel.stream.new  (stream="s2"="s2", batch:Boolean=true, batchSize:Number=2=2)

Start a generator in same flow

send::  msg testdiesel.streams.startGenerator  (stream="s2"="s2", howMany:Number=3=3)

val total:Array=[0] send::  msg diesel.stream.consume  (stream="s2"="s2", xtimeout:Number=1000=1000)

expect::  (total is [0,1,2,3,4,5])

Batch stream API

Creating a simple AIP for batch processing of JSON records.

Create a stream from this flow,

  • start a consumer in another flow
  • and then call the API with a separate flow to put elements in it.

send::  msg diesel.stream.new  (stream="s3"="s3")

send::  msg testdiesel.stream.consume  (stream="s3"="s3", xtimeout:Number=1000=1000)

send::  msg ctx.sleep  (duration:Number=1000=1000)

Spawn a separate flow to put items in the stream "s3" :

send::  msg snakk.text  (url ="/diesel/rest/putAllInS3"...="/diesel/r..., verb="POST"="POST", body:Array=[{rec:"rec...)

Timer generator example, for pollers

TODO timer geenrators

// $send diesel.stream.new(stream="s4") // Start a generator in same flow // $send testdiesel.streams.startGenerator(stream="s4", howMany=3) // $send diesel.stream.consume(stream="s1", xtimeout=1000) // $send ctx.log(x=total) // $expect (total is 15)

Batch processing: putAll and onDataSlice

send::  msg diesel.stream.new  (stream="s2"="s2", batch:Boolean=true, batchSize:Number=2=2)

Start a generator in same flow

send::  msg testdiesel.streams.startGenerator  (stream="s2"="s2", howMany:Number=3=3)

val total:Array=[0] send::  msg diesel.stream.consume  (stream="s2"="s2", xtimeout:Number=1000=1000)

expect::  (total is [0,1,2,3,4,5])


Was this useful?    

By: Razie | 2020-10-04 .. 2021-01-30 | Tags: story , dsl , streams


Viewed 215 times ( | History | Print ) this page.

You need to log in to post a comment!

© Copyright DieselApps, 2012-2022, all rights reserved.