Skip to content

Commit 90a135e

Browse files
committed
1 parent c6fe424 commit 90a135e

File tree

4 files changed

+126
-4
lines changed

4 files changed

+126
-4
lines changed

src/gql/StartWorker.gql

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
mutation StartWorker(
2+
$input: JSON! = "",
3+
$workerLabel: mutationInput_post_startWorker_workerLabel!
4+
) {
5+
startWorker(
6+
input: $input,
7+
workerLabel: $workerLabel
8+
)
9+
}

src/lib.rs

Lines changed: 52 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,16 +86,31 @@ pub use crate::deprecated::*;
8686
const SDK_VERSION: &str = "0.25";
8787

8888

89-
type EmailAddress = String;
89+
type UUID = String;
90+
type BigInt = String;
9091
type DateTime = String;
92+
type EmailAddress = String;
9193
type Metadata = String;
92-
type BigInt = String;
94+
type JSON = String;
9395
type B64JSON = String;
9496
type Latitude = f64;
9597
type Longitude = f64;
96-
type UUID = String;
98+
// type mutationInput_post_startWorker_workerLabel = String;
99+
100+
// pub enum mutationInput_post_startWorker_workerLabel {
101+
// addAffordance_kNNvisual,
102+
// solveGraph_Wkr,
103+
// solveGraphParametric_Wkr,
104+
// runLambda_Wkr,
105+
// saveDFG_Wkr,
106+
// loadDFG_Wkr,
107+
// simulateIMU,
108+
// runGenericMapper,
109+
// echo
110+
// }
97111

98112

113+
#[cfg(any(feature = "tokio", feature = "wasm", feature = "blocking"))]
99114
#[derive(GraphQLQuery)]
100115
#[graphql(
101116
schema_path = "src/schema.json",
@@ -105,6 +120,7 @@ type UUID = String;
105120
pub struct GetBlobEntry;
106121

107122

123+
#[cfg(any(feature = "tokio", feature = "wasm", feature = "blocking"))]
108124
#[derive(GraphQLQuery, Clone)]
109125
#[graphql(
110126
schema_path = "src/schema.json",
@@ -114,6 +130,7 @@ pub struct GetBlobEntry;
114130
pub struct ListAgents;
115131

116132

133+
#[cfg(any(feature = "tokio", feature = "wasm", feature = "blocking"))]
117134
#[derive(GraphQLQuery, Clone)]
118135
#[graphql(
119136
schema_path = "src/schema.json",
@@ -123,6 +140,7 @@ pub struct ListAgents;
123140
pub struct UpdateAgentMetadata;
124141

125142

143+
#[cfg(any(feature = "tokio", feature = "wasm", feature = "blocking"))]
126144
#[derive(GraphQLQuery, Clone)]
127145
#[graphql(
128146
schema_path = "src/schema.json",
@@ -132,6 +150,7 @@ pub struct UpdateAgentMetadata;
132150
pub struct GetAgents;
133151

134152

153+
#[cfg(any(feature = "tokio", feature = "wasm", feature = "blocking"))]
135154
#[derive(GraphQLQuery)]
136155
#[graphql(
137156
schema_path = "src/schema.json",
@@ -141,6 +160,7 @@ pub struct GetAgents;
141160
pub struct GetURS;
142161

143162

163+
#[cfg(any(feature = "tokio", feature = "wasm", feature = "blocking"))]
144164
#[derive(GraphQLQuery)]
145165
#[graphql(
146166
schema_path = "src/schema.json",
@@ -150,6 +170,7 @@ pub struct GetURS;
150170
pub struct ListModels;
151171

152172

173+
#[cfg(any(feature = "tokio", feature = "wasm", feature = "blocking"))]
153174
#[derive(GraphQLQuery)]
154175
#[graphql(
155176
schema_path = "src/schema.json",
@@ -158,6 +179,8 @@ pub struct ListModels;
158179
)]
159180
pub struct ListModelsGraphs;
160181

182+
183+
#[cfg(any(feature = "tokio", feature = "wasm", feature = "blocking"))]
161184
#[derive(GraphQLQuery)]
162185
#[graphql(
163186
schema_path = "src/schema.json",
@@ -166,6 +189,8 @@ pub struct ListModelsGraphs;
166189
)]
167190
pub struct GetAgentEntriesMetadata;
168191

192+
193+
#[cfg(any(feature = "tokio", feature = "wasm", feature = "blocking"))]
169194
#[derive(GraphQLQuery)]
170195
#[graphql(
171196
schema_path = "src/schema.json",
@@ -175,6 +200,7 @@ pub struct GetAgentEntriesMetadata;
175200
pub struct CreateDownload;
176201

177202

203+
#[cfg(any(feature = "tokio", feature = "wasm", feature = "blocking"))]
178204
#[derive(GraphQLQuery)]
179205
#[graphql(
180206
schema_path = "src/schema.json",
@@ -184,6 +210,7 @@ pub struct CreateDownload;
184210
pub struct CreateUpload;
185211

186212

213+
#[cfg(any(feature = "tokio", feature = "wasm", feature = "blocking"))]
187214
#[derive(GraphQLQuery)]
188215
#[graphql(
189216
schema_path = "src/schema.json",
@@ -193,6 +220,17 @@ pub struct CreateUpload;
193220
pub struct CompleteUpload;
194221

195222

223+
#[cfg(any(feature = "tokio", feature = "wasm", feature = "blocking"))]
224+
#[derive(GraphQLQuery)]
225+
#[graphql(
226+
schema_path = "src/schema.json",
227+
query_path = "src/gql/StartWorker.gql",
228+
response_derives = "Debug"
229+
)]
230+
pub struct StartWorker;
231+
232+
233+
#[cfg(any(feature = "tokio", feature = "wasm", feature = "blocking"))]
196234
#[derive(GraphQLQuery)]
197235
#[graphql(
198236
schema_path = "src/schema.json",
@@ -202,6 +240,7 @@ pub struct CompleteUpload;
202240
pub struct GetVariable;
203241

204242

243+
#[cfg(any(feature = "tokio", feature = "wasm", feature = "blocking"))]
205244
#[derive(GraphQLQuery)]
206245
#[graphql(
207246
schema_path = "src/schema.json",
@@ -212,6 +251,7 @@ pub struct ListVariables;
212251
// Implicit ListWhere due to graphql-client limitation: https://github.com/graphql-rust/graphql-client/issues/508
213252

214253

254+
#[cfg(any(feature = "tokio", feature = "wasm", feature = "blocking"))]
215255
#[derive(GraphQLQuery)]
216256
#[graphql(
217257
schema_path = "src/schema.json",
@@ -221,6 +261,7 @@ pub struct ListVariables;
221261
pub struct AddVariable;
222262

223263

264+
#[cfg(any(feature = "tokio", feature = "wasm", feature = "blocking"))]
224265
#[derive(GraphQLQuery)]
225266
#[graphql(
226267
schema_path = "src/schema.json",
@@ -230,6 +271,7 @@ pub struct AddVariable;
230271
pub struct AddBlobEntryAgent;
231272

232273

274+
#[cfg(any(feature = "tokio", feature = "wasm", feature = "blocking"))]
233275
#[derive(GraphQLQuery)]
234276
#[graphql(
235277
schema_path = "src/schema.json",
@@ -239,6 +281,7 @@ pub struct AddBlobEntryAgent;
239281
pub struct AddBlobEntryModel;
240282

241283

284+
#[cfg(any(feature = "tokio", feature = "wasm", feature = "blocking"))]
242285
#[derive(GraphQLQuery)]
243286
#[graphql(
244287
schema_path = "src/schema.json",
@@ -247,6 +290,7 @@ pub struct AddBlobEntryModel;
247290
)]
248291
pub struct DeleteBlobEntry;
249292

293+
#[cfg(any(feature = "tokio", feature = "wasm", feature = "blocking"))]
250294
#[derive(GraphQLQuery)]
251295
#[graphql(
252296
schema_path = "src/schema.json",
@@ -255,6 +299,7 @@ pub struct DeleteBlobEntry;
255299
)]
256300
pub struct DeleteBlob;
257301

302+
#[cfg(any(feature = "tokio", feature = "wasm", feature = "blocking"))]
258303
#[derive(GraphQLQuery)]
259304
#[graphql(
260305
schema_path = "src/schema.json",
@@ -264,6 +309,7 @@ pub struct DeleteBlob;
264309
pub struct GetOrg;
265310

266311

312+
#[cfg(any(feature = "tokio", feature = "wasm", feature = "blocking"))]
267313
#[derive(GraphQLQuery)]
268314
#[graphql(
269315
schema_path = "src/schema.json",
@@ -273,6 +319,7 @@ pub struct GetOrg;
273319
pub struct ListGraphs;
274320

275321

322+
#[cfg(any(feature = "tokio", feature = "wasm", feature = "blocking"))]
276323
#[derive(GraphQLQuery)]
277324
#[graphql(
278325
schema_path = "src/schema.json",
@@ -281,6 +328,7 @@ pub struct ListGraphs;
281328
)]
282329
pub struct AddAgent;
283330

331+
#[cfg(any(feature = "tokio", feature = "wasm", feature = "blocking"))]
284332
#[derive(GraphQLQuery)]
285333
#[graphql(
286334
schema_path = "src/schema.json",
@@ -289,6 +337,7 @@ pub struct AddAgent;
289337
)]
290338
pub struct AddModel;
291339

340+
#[cfg(any(feature = "tokio", feature = "wasm", feature = "blocking"))]
292341
#[derive(GraphQLQuery)]
293342
#[graphql(
294343
schema_path = "src/schema.json",

src/services.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,8 @@ pub use Factors::*;
5353
#[allow(non_snake_case)]
5454
pub mod LegacyURS;
5555
#[allow(non_snake_case)]
56-
pub use LegacyURS::*;
56+
pub use LegacyURS::*;
57+
58+
pub mod Worker;
59+
pub use Worker::*;
60+
// pub mod StartWorker;

src/services/Worker.rs

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
2+
#[cfg(any(feature = "tokio", feature = "wasm", feature = "blocking"))]
3+
use crate::{
4+
GraphQLQuery,
5+
NavAbilityClient,
6+
Error,
7+
GQLRequestError,
8+
check_deser,
9+
check_query_response_data,
10+
to_console_error,
11+
StartWorker,
12+
// start_worker
13+
};
14+
15+
16+
17+
18+
#[cfg(any(feature = "tokio", feature = "wasm", feature = "blocking"))]
19+
pub async fn post_start_worker(
20+
nvacl: &NavAbilityClient,
21+
input: &str,
22+
worker_label: crate::start_worker::mutationInput_post_startWorker_workerLabel
23+
) -> Result<String, Box<dyn Error>> {
24+
25+
use crate::GQLResponseEmptyError;
26+
let variables = crate::start_worker::Variables {
27+
input: input.to_string(),
28+
worker_label
29+
};
30+
31+
let request_body = StartWorker::build_query(variables);
32+
33+
let req_res = nvacl.client
34+
.post(&nvacl.apiurl)
35+
.json(&request_body)
36+
.send().await;
37+
38+
if let Err(ref re) = req_res {
39+
let erm = format!("API request error: {:?}", &re);
40+
to_console_error(&erm);
41+
return Err(Box::new(GQLRequestError { details: erm }));
42+
}
43+
44+
// generic transport and serde error checks
45+
let response_body = check_deser::<crate::start_worker::ResponseData>(
46+
req_res?.json().await
47+
);
48+
49+
// unwrap ListAgents query response during error checks
50+
return check_query_response_data(response_body, |s| {
51+
return s.start_worker.unwrap_or("{}".to_owned());
52+
});
53+
}
54+
55+
56+
57+
58+
59+
60+

0 commit comments

Comments
 (0)