Skip to content
This repository has been archived by the owner on Nov 6, 2023. It is now read-only.

Commit

Permalink
fix(max)!: make max optional, change meaning of 0
Browse files Browse the repository at this point in the history
Signed-off-by: Brooks Townsend <brooksmtownsend@gmail.com>
  • Loading branch information
brooksmtownsend committed Oct 6, 2023
1 parent 3e62423 commit bf79620
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "wasmcloud-control-interface"
version = "0.29.0"
version = "0.29.1"
authors = ["wasmCloud Team"]
edition = "2021"
homepage = "https://wasmcloud.com"
Expand Down
10 changes: 6 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,9 @@ impl<T: KvStore + Clone + Debug + Send + Sync> Client<T> {
count: u16,
annotations: Option<HashMap<String, String>>,
) -> Result<CtlOperationAck> {
self.scale_actor(host_id, actor_ref, count, annotations)
.await
// It makes no logical sense to start 0 actors, so we represent that as an unbounded max instead.
let max = if count == 0 { None } else { Some(count) };
self.scale_actor(host_id, actor_ref, max, annotations).await
}

/// Sends a request to the given host to scale a given actor. This returns an acknowledgement of
Expand All @@ -311,14 +312,15 @@ impl<T: KvStore + Clone + Debug + Send + Sync> Client<T> {
/// # Arguments
/// `host_id`: The ID of the host to scale the actor on
/// `actor_ref`: The OCI reference of the actor to scale
/// `max_concurrent`: The maximum number of instances this actor can run concurrently. Setting this value to 0 means there is no maximum.
/// `max_concurrent`: The maximum number of requests this actor handle run concurrently. `None` represents an unbounded
/// level of concurrency while `0` will stop the actor.
/// `annotations`: Optional annotations to apply to the actor
#[instrument(level = "debug", skip_all)]
pub async fn scale_actor(
&self,
host_id: &str,
actor_ref: &str,
max_concurrent: u16,
max_concurrent: Option<u16>,
annotations: Option<HashMap<String, String>>,
) -> Result<CtlOperationAck> {
let subject =
Expand Down
6 changes: 3 additions & 3 deletions src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,11 +244,11 @@ pub struct ScaleActorCommand {
/// example, autonomous agents may wish to "tag" scale requests as part of a given deployment
#[serde(default, skip_serializing_if = "Option::is_none")]
pub annotations: Option<AnnotationMap>,
/// The maximum number of concurrent executing instances of this actor. If omitted or set to
/// zero there is no maximum.
/// The maximum number of concurrent executing instances of this actor. If set to `None` there
/// there is no maximum, while setting to `0` will stop the actor.
// NOTE: renaming to `count` lets us remain backwards compatible for a few minor versions
#[serde(default, alias = "count", rename = "count")]
pub max_concurrent: u16,
pub max_concurrent: Option<u16>,
/// Host ID on which to scale this actor
#[serde(default)]
pub host_id: String,
Expand Down

0 comments on commit bf79620

Please sign in to comment.