https://github.com/sitetester/sync-point
Small web service with one endpoint: /wait-for-second-party/:unique-id which allows two parties to sync within a time limit
https://github.com/sitetester/sync-point
Last synced: 10 months ago
JSON representation
Small web service with one endpoint: /wait-for-second-party/:unique-id which allows two parties to sync within a time limit
- Host: GitHub
- URL: https://github.com/sitetester/sync-point
- Owner: sitetester
- Created: 2024-12-17T17:47:30.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-01-03T11:48:30.000Z (over 1 year ago)
- Last Synced: 2025-02-07T03:18:10.640Z (over 1 year ago)
- Language: Rust
- Homepage:
- Size: 53.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
It's small web service with one endpoint: `/wait-for-second-party/:unique-id`
This endpoint allows two parties to sync. When one party makes a POST request, the response will be delayed until the second party requests the same URL.
In other words, the first party is blocked until the second party arrives or a timeout occurs (e.g., 10 seconds).
### Setup
- `cargo run` (it will install dependencies & start Rocket web server). Example output
```aiignore
[2024-12-28T06:41:51Z WARN rocket::launch] 🚀 Rocket has launched from http://127.0.0.1:8000
```
---
### Testing
**via CURL**
- curl -X POST http://127.0.0.1:8000/wait-for-second-party/123 (from one terminal tab/window)
- curl -X POST http://127.0.0.1:8000/wait-for-second-party/123 (from another terminal tab/window)
If both parties join within the `timeout` duration (10 sec), it should return such JSON responses
```aiignore
{"status":"success","message":"Welcome! (first party)"}
{"status":"success","message":"Welcome! (second party)"}
```
but if only one party tries to join, then the timeout response should be
```aiignore
{"status":"timeout","message":"Request timed out","timeout_duration_sec":10}
```
**via cargo test**
2 types of tests are provided. Unit & Integration
- `src/api/app_state.rs` functionality is tested via unit tests, hence tests are provided in the same file.
- `tests/api.rs` while this file contains integration tests, covering different scenarios.
---