-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(rears-core): rename Observable -> Publisher and move test to…
… describe AnyFunSpec
- Loading branch information
Showing
7 changed files
with
80 additions
and
79 deletions.
There are no files selected for viewing
5 changes: 2 additions & 3 deletions
5
rears-core/src/main/scala/io/github/tassiLuca/rears/Boundary.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
rears-core/src/main/scala/io/github/tassiLuca/rears/Controller.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
package io.github.tassiLuca.rears | ||
|
||
import gears.async.{ChannelMultiplexer, Future, ReadableChannel, Task} | ||
import gears.async.{Async, ChannelMultiplexer, ReadableChannel, Task} | ||
|
||
object Controller: | ||
|
||
def oneToMany[T, R]( | ||
publisher: Observable[T], | ||
publisherChannel: ReadableChannel[T], | ||
consumers: Set[Consumer[R]], | ||
transformation: PipelineTransformation[T, R] = identity, | ||
): Task[Unit] = Task: | ||
val multiplexer = ChannelMultiplexer[R]() | ||
consumers.foreach(c => multiplexer.addSubscriber(c.listeningChannel)) | ||
multiplexer.addPublisher(transformation(publisher.publishingChannel)) | ||
multiplexer.addPublisher(transformation(publisherChannel)) | ||
// blocking call: the virtual thread on top of which this task is executed needs to block | ||
// to continue publishing publisher's events towards the consumer by means of the multiplexer. | ||
multiplexer.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 3 additions & 4 deletions
7
smart-home/src/main/scala/io/github/tassiLuca/smarthome/core/SensorSource.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
package io.github.tassiLuca.smarthome.core | ||
|
||
import io.github.tassiLuca.rears.Observable | ||
import io.github.tassiLuca.rears.Publisher | ||
|
||
/** A generic source of [[SensorEvent]]. */ | ||
trait SensorSource: | ||
val source: Observable[SensorEvent] | ||
trait SensorSource extends Publisher[SensorEvent] | ||
|
||
/** A detection performe by a sensing unit. */ | ||
/** A detection performed by a sensing unit. */ | ||
sealed trait SensorEvent(val name: String) | ||
case class TemperatureEntry(temperature: Double) extends SensorEvent("temperature") | ||
case class LuminosityEntry(luminosity: Double) extends SensorEvent("luminosity") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters