Some cleanup on the binding streams to topics.

main
Oliver Kennedy 2023-06-11 12:27:11 -04:00
parent d4b7a5c493
commit a026f99b27
Signed by: okennedy
GPG Key ID: 3E5F9B3ABD3FDB60
5 changed files with 22 additions and 2 deletions

View File

@ -11,7 +11,7 @@ object shingle extends ScalaModule
def internalJavaVersion = T {
try {
val jvm = System.getProperties().getProperty("java.version")
println(f"Running Vizier with `${jvm}`")
println(f"Running Shingle with `${jvm}`")
jvm.split("\\.")(0).toInt
} catch {
case _:NumberFormatException | _:ArrayIndexOutOfBoundsException => 8

View File

@ -1,6 +1,6 @@
#!/bin/bash
set -c
# set -c
HOST=heracles.xthemage.net
DIR=Documents/shingle/

View File

@ -1,5 +1,9 @@
package net.okennedy.shingle.stream
import upickle.default._
import net.okennedy.shingle.component.Mqtt
trait State[T]
{
def now: T
@ -21,4 +25,12 @@ class Checkpoint[T](init: Option[T] = None) extends State[T] with Sink[T] with D
__value = Some(incoming)
dispatch(incoming)
}
override def bind(topic: String)(implicit writer: Writer[T], owner: Owner): Checkpoint[T] =
{
val path = Mqtt(topic).isState
super.bind(topic)
__value.foreach { path << _ }
return this
}
}

View File

@ -4,6 +4,8 @@ import scala.collection.mutable
import upickle.default._
import ujson.Bool
import java.util.Arrays
import net.okennedy.shingle.component.Mqtt
import upickle.default._
trait Stream[T]
{
@ -80,6 +82,12 @@ trait Stream[T]
ret << this
return ret
}
def bind(topic: String)(implicit writer: Writer[T], owner: Owner): Stream[T] =
{
Mqtt(topic) << this
return this
}
}
trait Dispatchable[T] extends Stream[T]