116 lines
2.6 KiB
Markdown
116 lines
2.6 KiB
Markdown
|
|
# Clocker
|
|
|
|
## Sequence diagram
|
|
|
|
```plantuml
|
|
@startuml
|
|
participant FE as "Frontend" << React >>
|
|
participant Funnel as "Funnel" << Python >>
|
|
participant Segments as "ServeSegments" << Go >>
|
|
participant CurrentTime as "ServeCurrentTime" << NodeJS >>
|
|
|
|
activate FE #hotpink
|
|
FE -> FE: Load page
|
|
FE -> Funnel: WS Connect
|
|
|
|
loop #ivory
|
|
activate Funnel #gold
|
|
Funnel -> Segments: GetHours()
|
|
activate Segments #skyblue
|
|
Segments -> CurrentTime: GetCurrentTime()
|
|
activate CurrentTime #sandybrown
|
|
return HH:MM:SS.ms
|
|
return HH
|
|
|
|
Funnel -> Segments: GetMinutes()
|
|
activate Segments #skyblue
|
|
Segments -> CurrentTime: GetCurrentTime()
|
|
activate CurrentTime #sandybrown
|
|
return HH:MM:SS.ms
|
|
return MM
|
|
|
|
Funnel -> Segments: GetSeconds()
|
|
activate Segments #skyblue
|
|
Segments -> CurrentTime: GetCurrentTime()
|
|
activate CurrentTime #sandybrown
|
|
return HH:MM:SS.ms
|
|
return SS
|
|
|
|
Funnel -> Segments: GetMilliseconds()
|
|
activate Segments #skyblue
|
|
Segments -> CurrentTime: GetCurrentTime()
|
|
activate CurrentTime #sandybrown
|
|
return HH:MM:SS.ms
|
|
return ms
|
|
|
|
Funnel -> FE: WS: Send formatted time
|
|
deactivate Funnel
|
|
end
|
|
deactivate FE
|
|
|
|
@enduml
|
|
```
|
|
|
|
## Services
|
|
|
|
| Service | Language | Port |
|
|
| -- | -- | -- |
|
|
| Funnel | Python | - |
|
|
| ServeCurrentTime | NodeJS | 50000 |
|
|
| ServeSegments | Go | 50001 |
|
|
|
|
### Funnel
|
|
|
|
Requirements:
|
|
- python 3.8+
|
|
- grpcio
|
|
- grpcio-tools
|
|
|
|
Install virtualenv and libs
|
|
```sh
|
|
cd src/funnel
|
|
virtualenv env
|
|
source env/bin/activate
|
|
pip install -r requirements.txt
|
|
```
|
|
|
|
Compile proto stubs:
|
|
```sh
|
|
cd src/funnel
|
|
make proto
|
|
```
|
|
|
|
Run service:
|
|
```sh
|
|
cd src/funnel
|
|
make run
|
|
```
|
|
|
|
### Go services
|
|
|
|
[gRPC Source](https://github.com/grpc/grpc-go)
|
|
|
|
Install protobuf compiler
|
|
```sh
|
|
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28
|
|
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2
|
|
```
|
|
|
|
### Rust services
|
|
|
|
Update `rustc`
|
|
|
|
```sh
|
|
rustup update
|
|
```
|
|
|
|
#### [Tonic](https://github.com/hyperium/tonic)
|
|
|
|
Tonic is a gRPC over HTTP/2 implementation focused on high performance, interoperability, and flexibility. This library was created to have first class support of async/await and to act as a core building block for production systems written in Rust.
|
|
|
|
[Hello world tutorial](https://github.com/hyperium/tonic/blob/master/examples/helloworld-tutorial.md)
|
|
|
|
|
|
[Rust and gRPC: A complete guide](https://blog.logrocket.com/rust-and-grpc-a-complete-guide/)
|