Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/akbashev/swift-chat
https://github.com/akbashev/swift-chat
Last synced: 13 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/akbashev/swift-chat
- Owner: akbashev
- Created: 2023-08-03T10:40:51.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-04-03T08:08:48.000Z (7 months ago)
- Last Synced: 2024-04-03T09:28:24.209Z (7 months ago)
- Language: Swift
- Size: 128 KB
- Stars: 60
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# swift-chat
A simple chat made to play with [Distributed actors](https://www.swift.org/blog/distributed-actors/).
## Run
Swift 5.9 is needed (was playing with new Swift Foundations, although removed in the end).
1. Install `brew install postgresql`
2. Open `App/swift-chat.xcodeproj`
3. Configure scheme environment for Frontend node to run a database (DB_USERNAME, DB_PASSWORD and DB_NAME)
4. Run `standalone` node either through Xcode schemes or using command line tools. You need to provide info on which node and where you want to start, e.g. `standalone --host 127.0.0.1 --port 2550`.
Additionaly you can start seperate `frontend` and `room` nodes to play. Better start with frontend:
`frontend --host 127.0.0.1 --port 2550`
and then room:
`room --host 127.0.0.1 --port 2551`5. Open `swift-chat` app on device/simulator. Create user and room name, and connect. Open another instance on different device/simulator and connect to the room by entering same name.
## TODO:
(no priorities, so no order)
* ~~Check if actors are cleaned from memory when websocket disconnects.~~
* ~~Some database with simple event sourcing.~~
* ~~Basic clustering with fault tolerance. Check different scenarios like room node crashes and etc.~~
* ~~DATABASE NODE FAILURES ARE NOT HANDLED AT THE MOMENT~~
* ~~Currently Event sourcing is not there yet and rudimentary (without state, recovery and snapshoting). Invest some time into this.~~
* ~~Interesting to play with [Swift OpenAPI generator](https://github.com/apple/swift-openapi-generator).~~
* Add some basic documentation.
* Testing—at least covering `Room`, `User` and `UserRoomConnections` actors would be nice.
* Tracing—debugging is quite hard thing even on a single node. Add [Swift Distributed Tracing](https://github.com/apple/swift-distributed-tracing)
* Improve scalibility and fault tolerance:
1. Add [node discovery](https://swiftpackageindex.com/apple/swift-distributed-actors/main/documentation/distributedcluster/clustering#Automatic-Node-Discovery) logic.
2. Improve error handling.
* Spining some example on real device/vps to get more info and for fun :)
* TBD