Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions core-api/src/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,9 @@ pub trait SlotReservationContext: Send + Sync {
/// Returns the identity of the worker
fn worker_identity(&self) -> &str;

/// Returns the deployment version of the worker, if one is set.
fn worker_deployment_version(&self) -> &Option<WorkerDeploymentVersion>;

/// Returns the number of currently outstanding slot permits, whether used or un-used.
fn num_issued_slots(&self) -> usize;

Expand Down
7 changes: 6 additions & 1 deletion core/src/abstractions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use std::{
};
use temporal_sdk_core_api::worker::{
SlotKind, SlotMarkUsedContext, SlotReleaseContext, SlotReservationContext, SlotSupplier,
SlotSupplierPermit, WorkflowSlotKind,
SlotSupplierPermit, WorkerDeploymentVersion, WorkflowSlotKind,
};
use tokio::sync::watch;
use tokio_util::sync::CancellationToken;
Expand Down Expand Up @@ -47,6 +47,7 @@ pub(crate) struct MeteredPermitDealer<SK: SlotKind> {
pub(crate) struct PermitDealerContextData {
pub(crate) task_queue: String,
pub(crate) worker_identity: String,
pub(crate) worker_deployment_version: Option<WorkerDeploymentVersion>,
}

impl<SK> MeteredPermitDealer<SK>
Expand Down Expand Up @@ -170,6 +171,10 @@ impl<SK: SlotKind> SlotReservationContext for MeteredPermitDealer<SK> {
&self.context_data.worker_identity
}

fn worker_deployment_version(&self) -> &Option<WorkerDeploymentVersion> {
&self.context_data.worker_deployment_version
}

fn num_issued_slots(&self) -> usize {
*self.extant_permits.1.borrow()
}
Expand Down
1 change: 1 addition & 0 deletions core/src/worker/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ impl Worker {
let slot_context_data = Arc::new(PermitDealerContextData {
task_queue: config.task_queue.clone(),
worker_identity: config.client_identity_override.clone().unwrap_or_default(),
worker_deployment_version: config.computed_deployment_version(),
});
let wft_slots = MeteredPermitDealer::new(
tuner.workflow_task_slot_supplier(),
Expand Down
Loading