Skip to content

Small web service with one endpoint: /wait-for-second-party/:unique-id which allows two parties to sync within a time limit

Notifications You must be signed in to change notification settings

sitetester/sync-point

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

61 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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
[2024-12-28T06:41:51Z WARN  rocket::launch] 🚀 Rocket has launched from http://127.0.0.1:8000

Testing

via CURL

If both parties join within the timeout duration (10 sec), it should return such JSON responses

{"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

{"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.

About

Small web service with one endpoint: /wait-for-second-party/:unique-id which allows two parties to sync within a time limit

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages