Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: setup connections with bridge before spawn #277

Merged
merged 14 commits into from
Sep 7, 2023
Merged

Conversation

de-sh
Copy link
Contributor

@de-sh de-sh commented Aug 31, 2023

Closes #

Changes

Why?

Uplink should ensure there are no two action routes in config that might be clashing, thus ensure all actions routes are inserted into bridge before starting, failing if two of them clash.

Trials Performed

Trigger an action from platform: (update_firmware)
Screenshot from 2023-09-01 10-56-45


  �[2m2023-09-01T05:24:54.650975Z�[0m �[32m INFO�[0m �[1;32muplink::collector::downloader�[0m�[32m: �[32mDownloading from https://firmware.stage.bytebeam.io/api/v1/firmwares/new26/artifact into /var/tmp/ota/1001/update_firmware/new26�[0m

  �[2m2023-09-01T05:24:54.651207Z�[0m �[32m INFO�[0m �[1;32muplink::base::bridge�[0m�[32m: �[32mAction response = ActionResponse { action_id: "1559", device_id: None, sequence: 2, timestamp: 1693545894651, state: "Downloading", progress: 3, errors: [], done_response: None }�[0m

  �[2m2023-09-01T05:24:54.651248Z�[0m �[32m INFO�[0m �[1;32muplink::base::bridge�[0m�[32m: �[32mAction response = ActionResponse { action_id: "1559", device_id: None, sequence: 3, timestamp: 1693545894651, state: "Downloading", progress: 7, errors: [], done_response: None }�[0m

  �[2m2023-09-01T05:24:54.651258Z�[0m �[32m INFO�[0m �[1;32muplink::base::bridge�[0m�[32m: �[32mAction response = ActionResponse { action_id: "1559", device_id: None, sequence: 4, timestamp: 1693545894651, state: "Downloading", progress: 14, errors: [], done_response: None }�[0m
...
�[2m2023-09-01T05:24:54.749163Z�[0m �[32m INFO�[0m �[1;32muplink::base::bridge�[0m�[32m: �[32mAction response = ActionResponse { action_id: "1559", device_id: None, sequence: 17, timestamp: 1693545894749, state: "Downloaded", progress: 100, errors: [], done_response: Some(Action { device_id: None, action_id: "1559", kind: "process", name: "update_firmware", payload: "{\"url\":\"https://firmware.stage.bytebeam.io/api/v1/firmwares/new26/artifact\",\"content_length\":227862,\"file_name\":\"new26\",\"download_path\":\"/var/tmp/ota/1001/update_firmware/new26\"}" }) }�[0m
...
  �[2m2023-09-01T05:24:54.749871Z�[0m �[34mDEBUG�[0m �[1;34muplink::collector::tcpjson�[0m�[34m: �[34m1: Received line = "{\"stream\":\"action_status\",\"sequence\":1,\"timestamp\":1693545894749,\"action_id\":\"1559\",\"errors\":[],\"progress\":17,\"state\":\"in_progress\"}"�[0m

  �[2m2023-09-01T05:24:54.750139Z�[0m �[32m INFO�[0m �[1;32muplink::base::bridge�[0m�[32m: �[32mAction response = ActionResponse { action_id: "1559", device_id: None, sequence: 1, timestamp: 1693545894749, state: "in_progress", progress: 17, errors: [], done_response: None }�[0m

When two routes in config clash:
e.g. config

[tcpapps.1]
port = 5050
actions= [{ name = "load_file" }, { name = "update_firmware" }]

[downloader]
actions= [{ name = "send_file" }, { name = "update_firmware" }]
path = "/var/tmp/ota"

runtime:

thread 'main' panicked at uplink/src/base/bridge/mod.rs:192:17:
Action Route clash: update_firmware

@de-sh de-sh marked this pull request as draft August 31, 2023 14:41
@de-sh de-sh marked this pull request as ready for review September 1, 2023 05:53
@de-sh de-sh requested a review from tekjar September 1, 2023 05:55
uplink/src/lib.rs Outdated Show resolved Hide resolved
@de-sh de-sh merged commit 9dd3397 into main Sep 7, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants