trying to run a gitea workflow
Some checks failed
Some checks failed
This commit is contained in:
@@ -525,6 +525,28 @@ impl Connection {
|
||||
)
|
||||
.await?;
|
||||
|
||||
// --- Cancel queue ---
|
||||
// Each worker gets its own queue for execution cancel requests so that
|
||||
// the API can target a specific worker to gracefully stop a running process.
|
||||
let cancel_queue_name = format!("worker.{}.cancel", worker_id);
|
||||
let cancel_queue_config = QueueConfig {
|
||||
name: cancel_queue_name.clone(),
|
||||
durable: true,
|
||||
exclusive: false,
|
||||
auto_delete: false,
|
||||
};
|
||||
|
||||
self.declare_queue_with_optional_dlx(&cancel_queue_config, dlx)
|
||||
.await?;
|
||||
|
||||
// Bind to worker-specific cancel routing key on the executions exchange
|
||||
self.bind_queue(
|
||||
&cancel_queue_name,
|
||||
&config.rabbitmq.exchanges.executions.name,
|
||||
&format!("execution.cancel.worker.{}", worker_id),
|
||||
)
|
||||
.await?;
|
||||
|
||||
info!(
|
||||
"Worker infrastructure setup complete for worker ID {}",
|
||||
worker_id
|
||||
|
||||
@@ -67,6 +67,8 @@ pub enum MessageType {
|
||||
RuleDisabled,
|
||||
/// Pack registered or installed (triggers runtime environment setup in workers)
|
||||
PackRegistered,
|
||||
/// Execution cancel requested (sent to worker to gracefully stop a running execution)
|
||||
ExecutionCancelRequested,
|
||||
}
|
||||
|
||||
impl MessageType {
|
||||
@@ -85,6 +87,7 @@ impl MessageType {
|
||||
Self::RuleEnabled => "rule.enabled".to_string(),
|
||||
Self::RuleDisabled => "rule.disabled".to_string(),
|
||||
Self::PackRegistered => "pack.registered".to_string(),
|
||||
Self::ExecutionCancelRequested => "execution.cancel".to_string(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,6 +105,7 @@ impl MessageType {
|
||||
"attune.events".to_string()
|
||||
}
|
||||
Self::PackRegistered => "attune.events".to_string(),
|
||||
Self::ExecutionCancelRequested => "attune.executions".to_string(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,6 +124,7 @@ impl MessageType {
|
||||
Self::RuleEnabled => "RuleEnabled",
|
||||
Self::RuleDisabled => "RuleDisabled",
|
||||
Self::PackRegistered => "PackRegistered",
|
||||
Self::ExecutionCancelRequested => "ExecutionCancelRequested",
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -474,6 +479,19 @@ pub struct PackRegisteredPayload {
|
||||
pub runtime_names: Vec<String>,
|
||||
}
|
||||
|
||||
/// Payload for ExecutionCancelRequested message
|
||||
///
|
||||
/// Sent by the API to the worker that is running a specific execution,
|
||||
/// instructing it to gracefully terminate the process (SIGINT, then SIGTERM
|
||||
/// after a grace period).
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct ExecutionCancelRequestedPayload {
|
||||
/// Execution ID to cancel
|
||||
pub execution_id: Id,
|
||||
/// Worker ID that should handle this cancel (used for routing)
|
||||
pub worker_id: Id,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
@@ -57,10 +57,11 @@ pub use consumer::{Consumer, ConsumerConfig};
|
||||
pub use error::{MqError, MqResult};
|
||||
pub use message_queue::MessageQueue;
|
||||
pub use messages::{
|
||||
EnforcementCreatedPayload, EventCreatedPayload, ExecutionCompletedPayload,
|
||||
ExecutionRequestedPayload, ExecutionStatusChangedPayload, InquiryCreatedPayload,
|
||||
InquiryRespondedPayload, Message, MessageEnvelope, MessageType, NotificationCreatedPayload,
|
||||
PackRegisteredPayload, RuleCreatedPayload, RuleDisabledPayload, RuleEnabledPayload,
|
||||
EnforcementCreatedPayload, EventCreatedPayload, ExecutionCancelRequestedPayload,
|
||||
ExecutionCompletedPayload, ExecutionRequestedPayload, ExecutionStatusChangedPayload,
|
||||
InquiryCreatedPayload, InquiryRespondedPayload, Message, MessageEnvelope, MessageType,
|
||||
NotificationCreatedPayload, PackRegisteredPayload, RuleCreatedPayload, RuleDisabledPayload,
|
||||
RuleEnabledPayload,
|
||||
};
|
||||
pub use publisher::{Publisher, PublisherConfig};
|
||||
|
||||
@@ -224,6 +225,8 @@ pub mod routing_keys {
|
||||
pub const NOTIFICATION_CREATED: &str = "notification.created";
|
||||
/// Pack registered routing key
|
||||
pub const PACK_REGISTERED: &str = "pack.registered";
|
||||
/// Execution cancel requested routing key
|
||||
pub const EXECUTION_CANCEL: &str = "execution.cancel";
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
Reference in New Issue
Block a user