{"id":20059561,"url":"https://github.com/monix/monix-sample","last_synced_at":"2025-05-05T15:31:44.379Z","repository":{"id":53858942,"uuid":"41586299","full_name":"monix/monix-sample","owner":"monix","description":"A project exemplifying client / server communications with Monix.","archived":false,"fork":false,"pushed_at":"2017-04-03T13:22:20.000Z","size":276,"stargazers_count":100,"open_issues_count":0,"forks_count":16,"subscribers_count":13,"default_branch":"master","last_synced_at":"2024-05-21T04:20:54.213Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://monix.io","language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/monix.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-08-29T08:27:32.000Z","updated_at":"2024-02-23T01:25:34.000Z","dependencies_parsed_at":"2022-08-23T10:30:42.901Z","dependency_job_id":null,"html_url":"https://github.com/monix/monix-sample","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monix%2Fmonix-sample","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monix%2Fmonix-sample/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monix%2Fmonix-sample/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monix%2Fmonix-sample/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/monix","download_url":"https://codeload.github.com/monix/monix-sample/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224452805,"owners_count":17313668,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-13T13:08:22.738Z","updated_at":"2024-11-13T13:08:23.345Z","avatar_url":"https://github.com/monix.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Monix Client/Server Sample\n\nSample of a mixed client/server application demonstrating\nthe streaming of values over web-socket, both simple and with \nback-pressure applied (by means of the [Reactive Streams](http://www.reactive-streams.org/)\nprotocol), using [Monix](https://github.com/monix/monix) for both\nthe server and the client ;-)\n\nSee: **[monix-sample.herokuapp.com](http://monix-sample.herokuapp.com)**\n\n[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/monix/monix?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge)\n\nOverview of the code:\n\n- the server-side values generator is \n  in [engine.DataProducer](server/app/engine/DataProducer.scala)\n- the server-side WebSocket channel that implements the back-pressure\n  protocol as defined by [Reactive Streams](http://www.reactive-streams.org/) \n  is handled by \n  [engine.BackPressuredWebSocketActor](server/app/engine/BackPressuredWebSocketActor.scala) (using\n  Play's [WebSocket support](https://www.playframework.com/documentation/2.4.x/ScalaWebSockets#Handling-WebSockets-with-actors))\n  and the client-side consumer is \n  [client.BackPressuredWebSocketClient](client/src/main/scala/client/BackPressuredWebSocketClient.scala)\n- the server-side WebSocket channel that doesn't do back-pressure is\n  [engine.SimpleWebSocketActor](server/app/engine/SimpleWebSocketActor.scala)\n  while the client-side consumer is\n  [client.SimpleWebSocketClient](client/src/main/scala/client/SimpleWebSocketClient.scala)\n- the type-safe observable that listens to a server web-socket connection\n  generating signals is in \n  [client.DataConsumer](client/src/main/scala/client/DataConsumer.scala)\n- the integration with Epoch, our charting library, is in\n  [client.Graph](client/src/main/scala/client/Graph.scala)\n  \nNOTES:\n\n- we are exposing 2 versions of webSocket connections, one that is back-pressured\n  as a matter of the server-side protocol and one that is not\n- both versions are protected by buffers that start dropping events in case\n  the client is too slow, but the difference is that for the back-pressured \n  version the buffer is being maintained server-side\n- by applying back-pressure in the protocol, the server is informed of the \n  rate at which the client can consume and thus there is no risk for the\n  server in case we've got clients that are too slow; on the other hand for the\n  simple version the server can be crashed on clients that are too slow in \n  receiving their events, as that actor's mailbox is unbounded\n- the back-pressured version needs server-side cooperation / implementation and\n  is thus more difficult to develop\n  \nIn order to develop and execute the project locally:\n\n```\nsbt run\n```\n\nFor Heroku deployment:\n\n```\nsbt stage deployHeroku\n```\n\nThe project is based on the cool \n[play-with-scalajs-example](https://github.com/vmunier/play-with-scalajs-example)\ntemplate by [@vmunier](https://github.com/vmunier), so you get the auto-reload \ncoolness of Play in combination with Scala.js.\n\n~;Enjoy\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmonix%2Fmonix-sample","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmonix%2Fmonix-sample","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmonix%2Fmonix-sample/lists"}