Skip to content

Commit

Permalink
document push, also rename variables
Browse files Browse the repository at this point in the history
  • Loading branch information
jr1221 committed Jul 20, 2024
1 parent d464d2d commit 8df0ed7
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,18 @@ Examples:

Router deploy and send to background: `docker compose -f compose.yml -f compose.router.yml up -d`

### Build and deploy

Using the above profiles, one can `build` the app. Then, with correct permissions, you can `push` the app then `pull` it elsewhere for usage. Note that you must `push` and `pull` on the same architecture, so you cannot use for example a dell laptop to build for the router! To get `push` permissions, create a PAT [here](https://github.com/settings/tokens/new?scopes=write:packages) and copy the token into this command:

```
sudo docker login ghcr.io -u <gh username> -p <token>
```

Now you can update the image on a remote server. Note to save time you can just specify which service to upload, like `scylla-server-rust` or `client`.
```
sudo docker compose -f compose.yml -f compose.router.yml build && sudo docker compose -f compose.yml -f compose.router.yml push
```


## Codegen Protobuf Types (client only)
Expand Down
11 changes: 6 additions & 5 deletions scylla-server-rust/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,23 +56,24 @@ async fn main() {

// channel to pass the mqtt data
// TODO tune buffer size
let (tx, rx) = mpsc::channel::<ClientData>(10000);
let (mqtt_receive, mqtt_send) = mpsc::channel::<ClientData>(10000);

// channel to pass the processed data to the db thread
// TODO tune buffer size
let (tx_proc, rx_proc) = mpsc::channel::<Vec<ClientData>>(1000);
let (db_receive, db_send) = mpsc::channel::<Vec<ClientData>>(1000);

// the below two threads need to cancel cleanly to ensure all queued messages are sent. therefore they are part of the a task tracker group.
// create a task tracker and cancellation token
let task_tracker = TaskTracker::new();
let token = CancellationToken::new();
// spawn the database handler
task_tracker.spawn(
db_handler::DbHandler::new(rx, Arc::clone(&db)).handling_loop(tx_proc, token.clone()),
db_handler::DbHandler::new(mqtt_send, Arc::clone(&db))
.handling_loop(db_receive, token.clone()),
);
// spawn the database inserter
task_tracker.spawn(db_handler::DbHandler::batching_loop(
rx_proc,
db_send,
Arc::clone(&db),
token.clone(),
));
Expand All @@ -87,7 +88,7 @@ async fn main() {
// create and spawn the mqtt processor
info!("Running processor in MQTT (production) mode");
let (recv, eloop) = MqttProcessor::new(
tx,
mqtt_receive,
std::env::var("PROD_SIREN_HOST_URL").unwrap_or("localhost:1883".to_string()),
db.clone(),
io,
Expand Down
2 changes: 1 addition & 1 deletion scylla-server-rust/src/processors/mqtt_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ impl MqttProcessor {
})
.into_owned();

// parse time, if time isnt present use sys time (see above)
// parse time, if invalid time error out
let Ok(time_clean) = unix_time.1.parse::<i64>() else {
return Err(format!("Invalid timestamp: {}", unix_time.1));
};
Expand Down

0 comments on commit 8df0ed7

Please sign in to comment.