Skip to content
Merged

fmt #49

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
8 changes: 4 additions & 4 deletions examples/test_sse_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ struct TestActivity;

#[async_trait]
impl ActivityHandler for TestActivity {
fn activity_type(&self) -> String {
"test_activity".to_string()
}

async fn handle(
&self,
payload: serde_json::Value,
Expand All @@ -20,10 +24,6 @@ impl ActivityHandler for TestActivity {
println!("✅ Completed test activity");
Ok(Some(serde_json::json!({"status": "completed"})))
}

fn activity_type(&self) -> String {
"test_activity".to_string()
}
}

/// Example to test SSE event emission
Expand Down
12 changes: 6 additions & 6 deletions src/activity/activity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,12 @@ pub type ActivityHandlerResult<T = Option<serde_json::Value>> = Result<T, Activi
/// ```
#[async_trait]
pub trait ActivityHandler: Send + Sync {
/// Return the activity type string that this handler processes.
///
/// This string is used to match activities with their handlers when they are
/// registered with the worker engine. It should be unique and descriptive.
fn activity_type(&self) -> String;

/// Process the activity with the given payload and context.
///
/// This method is called by the worker engine to execute the activity.
Expand All @@ -367,12 +373,6 @@ pub trait ActivityHandler: Send + Sync {
context: ActivityContext,
) -> ActivityHandlerResult;

/// Return the activity type string that this handler processes.
///
/// This string is used to match activities with their handlers when they are
/// registered with the worker engine. It should be unique and descriptive.
fn activity_type(&self) -> String;

/// Called once when an activity enters the dead letter state.
///
/// This callback is triggered when an activity has exhausted all retry attempts
Expand Down