forked from coracle/caravel
85d37f53ce
Co-authored-by: userAdityaa <aditya.chaudhary1558@gmail.com> Co-committed-by: userAdityaa <aditya.chaudhary1558@gmail.com>
1.3 KiB
1.3 KiB
pub struct Infra
Infra is a service which listens for activity and synchronizes relay updates to a remote zooid instance via api_url.
Members:
api_url: String- the URL of the zooid instance to be managed, fromZOOID_API_URLquery: Querycommand: Command
pub fn new(query: Query, command: Command) -> Self
- Reads environment and populates members
pub async fn start(self)
- Subscribes to
command.notify - Loops on
rx.recv(), callinghandle_activityfor each receivedActivity.
async fn handle_activity(&self, activity: &Activity)
- For
create_relay,update_relay,activate_relay, ordeactivate_relayactivity, callssync_and_report. - All other activity types are ignored (e.g.
fail_relay_sync,complete_relay_sync).
async fn sync_and_report(&self, relay: &Relay, is_new: bool)
- Calls
sync_relayand on success callscommand.complete_relay_sync. - On failure calls
command.fail_relay_sync.
async fn sync_relay(&self, relay: &Relay, is_new: bool)
- If
is_new, sendsPOST /relay/:idto create the relay in zooid. - Otherwise, sends
PUT /relay/:idto update it. - Passes full relay configuration in the body including host, schema, secret, inactive flag, info, policy, groups, management, blossom, livekit, push, and roles.