@@ -31,14 +31,12 @@ impl WorkflowHandler {
31
31
32
32
pub ( crate ) async fn handle_compute (
33
33
node : & mut DriaComputeNode ,
34
- message : DKNMessage ,
34
+ compute_message : & DKNMessage ,
35
35
) -> Result < Either < MessageAcceptance , WorkflowsWorkerInput > > {
36
- let task = message
36
+ let stats = TaskStats :: new ( ) . record_received_at ( ) ;
37
+ let task = compute_message
37
38
. parse_payload :: < TaskRequestPayload < WorkflowPayload > > ( true )
38
- . wrap_err ( "Could not parse workflow task" ) ?;
39
-
40
- // TODO: !!!
41
- let task_stats = TaskStats :: default ( ) . record_received_at ( ) ;
39
+ . wrap_err ( "could not parse workflow task" ) ?;
42
40
43
41
// check if deadline is past or not
44
42
let current_time = get_current_time_nanos ( ) ;
@@ -106,15 +104,15 @@ impl WorkflowHandler {
106
104
model_name,
107
105
task_id : task. task_id ,
108
106
public_key : task_public_key,
109
- stats : task_stats ,
107
+ stats,
110
108
} ) )
111
109
}
112
110
113
111
pub ( crate ) async fn handle_publish (
114
112
node : & mut DriaComputeNode ,
115
113
task : WorkflowsWorkerOutput ,
116
- ) -> Result < MessageAcceptance > {
117
- let ( message, acceptance ) = match task. result {
114
+ ) -> Result < ( ) > {
115
+ let message = match task. result {
118
116
Ok ( result) => {
119
117
// prepare signed and encrypted payload
120
118
let payload = TaskResponsePayload :: new (
@@ -126,17 +124,16 @@ impl WorkflowHandler {
126
124
task. stats . record_published_at ( ) ,
127
125
) ?;
128
126
let payload_str = serde_json:: to_string ( & payload)
129
- . wrap_err ( "Could not serialize response payload" ) ?;
127
+ . wrap_err ( "could not serialize response payload" ) ?;
130
128
131
129
// prepare signed message
132
130
log:: debug!(
133
131
"Publishing result for task {}\n {}" ,
134
132
task. task_id,
135
133
payload_str
136
134
) ;
137
- let message = DKNMessage :: new ( payload_str, Self :: RESPONSE_TOPIC ) ;
138
- // accept so that if there are others included in filter they can do the task
139
- ( message, MessageAcceptance :: Accept )
135
+
136
+ DKNMessage :: new ( payload_str, Self :: RESPONSE_TOPIC )
140
137
}
141
138
Err ( err) => {
142
139
// use pretty display string for error logging with causes
@@ -151,22 +148,20 @@ impl WorkflowHandler {
151
148
stats : task. stats . record_published_at ( ) ,
152
149
} ;
153
150
let error_payload_str = serde_json:: to_string ( & error_payload)
154
- . wrap_err ( "Could not serialize error payload" ) ?;
151
+ . wrap_err ( "could not serialize error payload" ) ?;
155
152
156
153
// prepare signed message
157
- let message = DKNMessage :: new_signed (
154
+ DKNMessage :: new_signed (
158
155
error_payload_str,
159
156
Self :: RESPONSE_TOPIC ,
160
157
& node. config . secret_key ,
161
- ) ;
162
- // ignore just in case, workflow may be bugged
163
- ( message, MessageAcceptance :: Ignore )
158
+ )
164
159
}
165
160
} ;
166
161
167
162
// try publishing the result
168
163
if let Err ( publish_err) = node. publish ( message) . await {
169
- let err_msg = format ! ( "Could not publish result: {:?}" , publish_err) ;
164
+ let err_msg = format ! ( "could not publish result: {:?}" , publish_err) ;
170
165
log:: error!( "{}" , err_msg) ;
171
166
172
167
let payload = serde_json:: json!( {
@@ -181,6 +176,6 @@ impl WorkflowHandler {
181
176
node. publish ( message) . await ?;
182
177
} ;
183
178
184
- Ok ( acceptance )
179
+ Ok ( ( ) )
185
180
}
186
181
}
0 commit comments