(&self, input: DeployStationInput)
| 129 | /// Deploys a new station for the user and returns its id. |
| 130 | #[with_middleware(tail = use_canister_call_metric("deploy_station", &result))] |
| 131 | async fn deploy_station(&self, input: DeployStationInput) -> ApiResult<DeployStationResponse> { |
| 132 | let ctx = CallContext::get(); |
| 133 | let config = canister_config().ok_or(DeployError::Failed { |
| 134 | reason: "Canister config not initialized.".to_string(), |
| 135 | })?; |
| 136 | let max_concurrency = config |
| 137 | .global_rate_limiter |
| 138 | .remaining_quota() |
| 139 | .ok_or(UserError::DeployStationQuotaExceeded)?; |
| 140 | let _lock = STATE |
| 141 | .with(|state| { |
| 142 | CallerGuard::new( |
| 143 | state.clone(), |
| 144 | ctx.caller(), |
| 145 | CallerGuardParams::default().with_max_concurrency(max_concurrency), |
| 146 | ) |
| 147 | }) |
| 148 | .ok_or(UserError::ConcurrentStationDeployment)?; |
| 149 | |
| 150 | let deployed_station_id = self.deploy_service.deploy_station(input, &ctx).await?; |
| 151 | |
| 152 | Ok(DeployStationResponse { |
| 153 | canister_id: deployed_station_id, |
| 154 | }) |
| 155 | } |
| 156 | |
| 157 | /// Checks if the user can deploy a new station. |
| 158 | async fn can_deploy_station(&self) -> ApiResult<CanDeployStationResponse> { |
no test coverage detected