diff --git a/README.md b/README.md index e8422f6a..a85d7797 100644 --- a/README.md +++ b/README.md @@ -51,12 +51,20 @@ direct-style-experiments └── smart-hub-direct-kt # smart hub example using Kotlin Coroutines ``` +**IMPORTANT NOTE: Examples works with a version of the JDK > 21** (Virtual Threads are needed!). + +To build and run all the tests: + +``` +./gradlew build +``` + Generally speaking, the runnable examples can be run by simply executing the `run` Gradle task in the respective submodule, like: -```bash +``` ./gradlew :analyzer-direct:run ``` -Detailed instructions follows in the specific sections (and in `README`). +Detailed instructions can be found in the `README` file of the submodule and in the [documentation](https://tassiluca.github.io/direct-style-experiments/). -**Examples works with a version of the JDK > 21** (Virtual Threads are needed!). \ No newline at end of file +The documentation can be found [here](https://tassiluca.github.io/direct-style-experiments/). diff --git a/analyzer-direct-kt/README.md b/analyzer-direct-kt/README.md new file mode 100644 index 00000000..fdd1ed81 --- /dev/null +++ b/analyzer-direct-kt/README.md @@ -0,0 +1,19 @@ +# Analyzer example - Kotlin Coroutines version + +To run the example: + +``` +./gradlew :analyzer-direct-kt:run +``` + +In order to run the application you need to place inside the `analyzer-commons` directory a `.env` file containing [your personal GitHub access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens), like: + +```env +GH_TOKEN=.... +``` + +or having set an environment variable named `GH_TOKEN`. + +![Analyzer example](../docs/content/res/img/analyzer-e2e.png) + +Have a look to [the documentation](https://tassiluca.github.io/direct-style-experiments/docs/03-channels/) for more details. diff --git a/analyzer-direct/README.md b/analyzer-direct/README.md new file mode 100644 index 00000000..7fb21e26 --- /dev/null +++ b/analyzer-direct/README.md @@ -0,0 +1,19 @@ +# Analyzer example - Scala Gears version + +To run the example: + +``` +./gradlew :analyzer-direct:run +``` + +In order to run the application you need to place inside the `analyzer-commons` directory a `.env` file containing [your personal GitHub access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens), like: + +```env +GH_TOKEN=.... +``` + +or having set an environment variable named `GH_TOKEN`. + +![Analyzer example](../docs/content/res/img/analyzer-e2e.png) + +Have a look to [the documentation](https://tassiluca.github.io/direct-style-experiments/docs/03-channels/) for more details. diff --git a/analyzer-monadic/README.md b/analyzer-monadic/README.md new file mode 100644 index 00000000..fd9df9af --- /dev/null +++ b/analyzer-monadic/README.md @@ -0,0 +1,21 @@ +# Analyzer example - monadic `Future` version + +To run the example: + +``` +./gradlew :analyzer-direct:run +``` + +In order to run the application you need to place inside the `analyzer-commons` directory a `.env` file containing [your personal GitHub access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens), like: + +```env +GH_TOKEN=.... +``` + +or having set an environment variable named `GH_TOKEN`. + +![Analyzer example](../docs/content/res/img/analyzer-e2e.png) + +Warning: Incremental retrieval of results from the github api using pagination has not been implemented for this version (the data displayed may therefore be partial) + +Have a look to [the documentation](https://tassiluca.github.io/direct-style-experiments/docs/03-channels/) for more details. diff --git a/analyzer-monadic/src/main/scala/io/github/tassiLuca/analyzer/lib/RepositoryService.scala b/analyzer-monadic/src/main/scala/io/github/tassiLuca/analyzer/lib/RepositoryService.scala index 0b83a2fa..e56fb023 100644 --- a/analyzer-monadic/src/main/scala/io/github/tassiLuca/analyzer/lib/RepositoryService.scala +++ b/analyzer-monadic/src/main/scala/io/github/tassiLuca/analyzer/lib/RepositoryService.scala @@ -35,13 +35,13 @@ object RepositoryService: private val request = basicRequest.auth.bearer(System.getenv("GH_TOKEN")) override def repositoriesOf(organizationName: String): EitherT[Task, String, Seq[Repository]] = - performRequest[Seq[Repository]](uri"$apiUrl/orgs/$organizationName/repos") + performRequest[Seq[Repository]](uri"$apiUrl/orgs/$organizationName/repos?per_page=100") override def contributorsOf( organizationName: String, repositoryName: String, ): EitherT[Task, String, Seq[Contribution]] = - performRequest[Seq[Contribution]](uri"$apiUrl/repos/$organizationName/$repositoryName/contributors") + performRequest[Seq[Contribution]](uri"$apiUrl/repos/$organizationName/$repositoryName/contributors?per_page=100") override def lastReleaseOf( organizationName: String, diff --git a/blog-ws-direct-kt/README.md b/blog-ws-direct-kt/README.md new file mode 100644 index 00000000..c1138ef8 --- /dev/null +++ b/blog-ws-direct-kt/README.md @@ -0,0 +1,10 @@ +# Blog web service - Kotlin Coroutine version + +For this example just the tests are provided. You can explore them in the `test` folder. +To execute the tests, run: + +``` +./gradlew :blog-ws-direct-kt:test +``` + +Have a look to [the documentation](https://tassiluca.github.io/direct-style-experiments/docs/02-basics/) for more details. diff --git a/blog-ws-direct/README.md b/blog-ws-direct/README.md new file mode 100644 index 00000000..fc3920e4 --- /dev/null +++ b/blog-ws-direct/README.md @@ -0,0 +1,10 @@ +# Blog web service - Scala Gears version + +For this example just the tests are provided. You can explore them in the `test` folder. +To execute the tests, run: + +``` +./gradlew :blog-ws-direct:test +``` + +Have a look to [the documentation](https://tassiluca.github.io/direct-style-experiments/docs/02-basics/) for more details. diff --git a/blog-ws-monadic/README.md b/blog-ws-monadic/README.md new file mode 100644 index 00000000..5cd6dcdf --- /dev/null +++ b/blog-ws-monadic/README.md @@ -0,0 +1,10 @@ +# Blog web service - monadic `Future` version + +For this example just the tests are provided. You can explore them in the `test` folder. +To execute the tests, run: + +``` +./gradlew :blog-ws-monadic:test +``` + +Have a look to [the documentation](https://tassiluca.github.io/direct-style-experiments/docs/02-basics/) for more details. diff --git a/docs/content/_index.md b/docs/content/_index.md index 8c0f0c09..42c0e645 100644 --- a/docs/content/_index.md +++ b/docs/content/_index.md @@ -51,12 +51,18 @@ direct-style-experiments └── smart-hub-direct-kt # smart hub example using Kotlin Coroutines ``` +**IMPORTANT NOTE: Examples works with a version of the JDK > 21** (Virtual Threads are needed!). + +To build and run all the tests: + +``` +./gradlew build +``` + Generally speaking, the runnable examples can be run by simply executing the `run` Gradle task in the respective submodule, like: -```bash +``` ./gradlew :analyzer-direct:run ``` -Detailed instructions follows in the specific sections (and in `README`). - -**Examples works with a version of the JDK > 21** (Virtual Threads are needed!). +Detailed instructions can be found in the `README` file of each submodule and in the [documentation](https://tassiluca.github.io/direct-style-experiments/). diff --git a/docs/content/docs/03-channels.md b/docs/content/docs/03-channels.md index 51eb917b..d4e9f4c7 100644 --- a/docs/content/docs/03-channels.md +++ b/docs/content/docs/03-channels.md @@ -450,7 +450,7 @@ To start the application: {{< hint warning >}} -In order to use the application you need to place inside the `analyzer-commons` module a `.env` file containing [your personal GitHub access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens), like: +In order to run the application you need to place inside the `analyzer-commons` directory a `.env` file containing [your personal GitHub access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens), like: ```env GH_TOKEN=.... diff --git a/docs/content/docs/04-rears.md b/docs/content/docs/04-rears.md index 9e5bf5c4..a8b35035 100644 --- a/docs/content/docs/04-rears.md +++ b/docs/content/docs/04-rears.md @@ -478,7 +478,7 @@ The example is runnable via: ``` Three panels should pop up, one for each sensor type, and a dashboard showing the state of the system. -Entering some value in the panels and pressing the "Send" button, after 5 seconds (the configured sampling window), the system should react to the data received, updating the dashboard with the new state. +Entering some value in the panels and pressing the "Send" button, after 10 seconds (the configured sampling window), the system should react to the data received, updating the dashboard with the new state. {{< figure src="../../res/img/smart-hub.png" alt="Smart Hub application" width="90%" >}} diff --git a/smart-hub-direct-kt/README.md b/smart-hub-direct-kt/README.md new file mode 100644 index 00000000..3fa2ff2d --- /dev/null +++ b/smart-hub-direct-kt/README.md @@ -0,0 +1,14 @@ +# Smart hub example - Kotlin Coroutines version + +To run the example: + +``` +./gradlew :smart-hub-direct-kt:run +``` + +Three panels should pop up, one for each sensor type, and a dashboard showing the state of the system. +Entering some value in the panels and pressing the "Send" button, after 10 seconds (the configured sampling window), the system should react to the data received, updating the dashboard with the new state. + +![Smart hub example](../docs/content/res/img/smart-hub.png) + +Have a look to [the documentation](https://tassiluca.github.io/direct-style-experiments/docs/04-rears/) for more details. diff --git a/smart-hub-direct/README.md b/smart-hub-direct/README.md new file mode 100644 index 00000000..cd33d34b --- /dev/null +++ b/smart-hub-direct/README.md @@ -0,0 +1,14 @@ +# Smart hub example - Scala Gears version + +To run the example: + +``` +./gradlew :smart-hub-direct:run +``` + +Three panels should pop up, one for each sensor type, and a dashboard showing the state of the system. +Entering some value in the panels and pressing the "Send" button, after 10 seconds (the configured sampling window), the system should react to the data received, updating the dashboard with the new state. + +![Smart hub example](../docs/content/res/img/smart-hub.png) + +Have a look to [the documentation](https://tassiluca.github.io/direct-style-experiments/docs/04-rears/) for more details. diff --git a/smart-hub-direct/src/main/scala/io/github/tassiLuca/hub/application/LightingManager.scala b/smart-hub-direct/src/main/scala/io/github/tassiLuca/hub/application/LightingManager.scala index 9f977c96..5f5b27ee 100644 --- a/smart-hub-direct/src/main/scala/io/github/tassiLuca/hub/application/LightingManager.scala +++ b/smart-hub-direct/src/main/scala/io/github/tassiLuca/hub/application/LightingManager.scala @@ -11,7 +11,7 @@ import scala.language.postfixOps /** The hub managing the lighting system. */ trait LightingManager extends LightingSystemComponent with LampsComponent with DashboardServiceComponent: override val lightingSystem: LightingSystem = LightingSystem() - private val samplingWindow = 5 seconds + private val samplingWindow = 10 seconds /** Runs the manager, spawning a new controller consuming the given [[source]] of events. */ def run(source: ReadableChannel[LuminosityEntry])(using Async, AsyncOperations): Unit = diff --git a/smart-hub-direct/src/main/scala/io/github/tassiLuca/hub/application/ThermostatManager.scala b/smart-hub-direct/src/main/scala/io/github/tassiLuca/hub/application/ThermostatManager.scala index 65dc1250..2e1121ce 100644 --- a/smart-hub-direct/src/main/scala/io/github/tassiLuca/hub/application/ThermostatManager.scala +++ b/smart-hub-direct/src/main/scala/io/github/tassiLuca/hub/application/ThermostatManager.scala @@ -23,7 +23,7 @@ trait ThermostatManager with DashboardServiceComponent: override val thermostat: Thermostat = Thermostat(ThermostatScheduler.byHour(19)) override val sensorHealthChecker: SensorHealthChecker = SensorHealthChecker() - private val samplingWindow = 5 seconds + private val samplingWindow = 10 seconds /** Runs the manager, spawning a new controller consuming the given [[source]] of events. */ def run(source: ReadableChannel[TemperatureEntry])(using Async, AsyncOperations): Unit = diff --git a/smart-hub-direct/src/test/scala/io/github/tassiLuca/hub/application/TestableManagers.scala b/smart-hub-direct/src/test/scala/io/github/tassiLuca/hub/application/TestableManagers.scala index 6a031ed2..1caa8415 100644 --- a/smart-hub-direct/src/test/scala/io/github/tassiLuca/hub/application/TestableManagers.scala +++ b/smart-hub-direct/src/test/scala/io/github/tassiLuca/hub/application/TestableManagers.scala @@ -5,7 +5,7 @@ import io.github.tassiLuca.hub.core.{Luminosity, Temperature} import scala.concurrent.duration.DurationInt -val samplingWindow = 5.seconds +val samplingWindow = 10.seconds enum Message: case HeaterOn, HeaterOff, Alert, HeaterGetState, TemperatureUpdate, LuminosityUpdate, LightingOff, LightingOn