Skip to content
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.

Commit

Permalink
Merge pull request #15 from golemcloud/update-api
Browse files Browse the repository at this point in the history
update golem clients
  • Loading branch information
senia-psm authored Sep 6, 2023
2 parents 9ffae11 + 4d6115b commit 076374e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 24 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ clap = { version = "4.4.1", features = ["derive"] }
clap-verbosity-flag = "2.0.1"
derive_more = "0.99.17"
futures-util = "0.3.28"
golem-client = "0.0.31"
golem-client = "0.0.32"
golem-examples = "0.1.3"
http = "0.2.9"
indoc = "2.0.3"
Expand Down
29 changes: 8 additions & 21 deletions src/clients/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ use crate::model::{GolemError, InvocationKey, RawTemplateId};
use crate::WorkerName;
use async_trait::async_trait;
use futures_util::{future, pin_mut, SinkExt, StreamExt};
use golem_client::model::{ComponentInstance, InstanceMetadata, InvokeParameters, InvokeResult};
use golem_client::model::{
ComponentInstance, InstanceMetadata, InvokeParameters, InvokeResult, WorkerCreationRequest,
};
use reqwest::Url;
use serde::Deserialize;
use std::fmt::{Display, Formatter};
Expand Down Expand Up @@ -101,30 +103,15 @@ impl<C: golem_client::instance::Instance + Send + Sync> WorkerClient for WorkerC
) -> Result<ComponentInstance, GolemError> {
info!("Creating worker {name} of {}", template_id.0);

let args = if args.is_empty() {
None
} else {
Some(args.join(",")) // TODO: use json
};

let env = if env.is_empty() {
None
} else {
Some(
env.into_iter()
.map(|(k, v)| format!("{k}={v}"))
.collect::<Vec<String>>()
.join(","),
) // TODO use json
};

Ok(self
.client
.launch_new_instance(
&template_id.0.to_string(),
&name.0,
args.as_deref(),
env.as_deref(),
WorkerCreationRequest {
name: name.0,
args,
env,
},
&auth.header(),
)
.await?)
Expand Down

0 comments on commit 076374e

Please sign in to comment.