streams-spec Pub Share

============ diesel.rest streaming

$when:: diesel.rest (path ~path "/testdiesel/streamsample")
   . (stream="stream${diesel.engine.id}")
   diesel.stream.new (stream)
   testdiesel.streams.generate (stream, howMany:Number=5=5, delay:Number=500=500)
   . (payload=dieselStream)

Diesel streaming features

Start the stream value generators

$when:: testdiesel.streams.startGenerator (stream, howMany)
   testdiesel.streams.generate (stream, howMany)

$when:: testdiesel.streams.generate (stream, howMany, delay?)
   diesel.stream.put (stream, data:Number=1=1)
   $ifc:: (delay is defined) ctx.sleep (duration=delay)
   diesel.stream.put (stream, data:Number=2=2)
   $ifc:: (delay is defined) ctx.sleep (duration=delay)
   diesel.stream.put (stream, data:Number=3=3)
   $ifc:: (delay is defined) ctx.sleep (duration=delay)
   diesel.stream.putAll (stream, data :Array=[..]=[4,5])
   diesel.stream.done (stream)

$when:: diesel.stream.onData (stream == "s1", data)
   ctx.echo (total=total)
   ctx.echo (data=data)
   . (dieselScope[="total"]=(total + data))

$when:: diesel.stream.onDone (stream)
   ctx.echo (heh="done ${stream}"="done ${st...)

$when:: diesel.stream.onDataSlice (stream == "s2", data)
   ctx.echo (data=data)
   . (dieselScope[="total"]=(total + data))

API based

separate flow to consume

$when:: testdiesel.stream.consume (stream)
   diesel.stream.consume (stream)

separate flow to create

$when:: diesel.rest (path ~path "/putAllInS3")
   ctx.echo (data=payload)
   diesel.stream.putAll (stream="s3"="s3", data=payload)
   diesel.stream.done (stream="s3"="s3")

TODO when diesel.stream.cron (name, timeout)

$when:: testdiesel.streams.generate (stream, howMany)
   diesel.stream.put (stream, data:Number=1=1)
   diesel.stream.put (stream, data:Number=2=2)

$when:: testdiesel.crontick
   . (dieselRealm[="testcron"]=(dieselRealm[="testcron"] + 1))
   ctx.echo (x=dieselReal..., y=diesel[="r...)
   . (payload="testcron = ${diesel.realm.props.testcron}")

$when:: testdiesel.crondone (name)
   . (dieselRealm[="testcron"]=(dieselRealm[="testcron"] + name))
   ctx.echo (x=dieselReal..., y=diesel[="r...)
   . (payload="testcron = ${diesel.realm.props.testcron}")

$when:: testdiesel.crontickEX
   . (dieselRealm[="testcronEX"]=(dieselRealm[="testcronEX"] + 1))
   ctx.echo (x=dieselReal..., y=diesel[="r...)
   . (payload="testcron = ${diesel.realm.props.testcronEX}")


Was this useful?    

By: Razie | 2020-10-04 .. 2021-02-02 | Tags: spec , dsl , private


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

You need to log in to post a comment!

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