-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunction_client_impl.rs
More file actions
52 lines (47 loc) · 1.83 KB
/
function_client_impl.rs
File metadata and controls
52 lines (47 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
use crate::command::push::auth::get_authorization_metadata;
use tonic::Extensions;
use tonic::Request;
use tonic::transport::Channel;
use tucana::sagittarius::RuntimeFunctionDefinitionUpdateRequest as SagittariusRuntimeFunctionUpdateRequest;
use tucana::sagittarius::runtime_function_definition_service_client::RuntimeFunctionDefinitionServiceClient;
use tucana::shared::RuntimeFunctionDefinition;
pub struct SagittariusRuntimeFunctionServiceClient {
client: RuntimeFunctionDefinitionServiceClient<Channel>,
token: String,
}
impl SagittariusRuntimeFunctionServiceClient {
pub async fn new(sagittarius_url: String, token: String) -> Self {
let client = match RuntimeFunctionDefinitionServiceClient::connect(sagittarius_url).await {
Ok(client) => {
log::info!("Successfully connected to Sagittarius RuntimeFunction Endpoint!");
client
}
Err(err) => panic!(
"Failed to connect to Sagittarius (RuntimeFunction Endpoint): {:?}",
err
),
};
Self { client, token }
}
pub async fn update_runtime_function_definitions(
&mut self,
runtime_functions: Vec<RuntimeFunctionDefinition>,
) {
let request = Request::from_parts(
get_authorization_metadata(&self.token),
Extensions::new(),
SagittariusRuntimeFunctionUpdateRequest { runtime_functions },
);
match self.client.update(request).await {
Ok(response) => {
log::info!(
"Successfully transferred RuntimeFunctions. Did Sagittarius updated them? {:?}",
&response
);
}
Err(err) => {
log::error!("Failed to update RuntimeFunctions: {:?}", err);
}
};
}
}