@@ -80,7 +80,7 @@ impl<T> TemporalDeserializable for T {}
80
80
mod tests {
81
81
use super :: * ;
82
82
use futures:: FutureExt ;
83
- use std:: collections:: HashMap ;
83
+ use std:: { collections:: HashMap , marker :: PhantomData } ;
84
84
85
85
// Workflow implementation example
86
86
struct MyWorkflow {
@@ -112,6 +112,7 @@ mod tests {
112
112
}
113
113
}
114
114
115
+ // #[workflow] miiiight be necessary here, but, ideally is not.
115
116
impl MyWorkflow {
116
117
// Attrib commented out since nonexistent for now, but that's what it'd look like.
117
118
// #[signal]
@@ -123,4 +124,37 @@ mod tests {
123
124
self . bar . get ( & arg) . cloned ( )
124
125
}
125
126
}
127
+
128
+ // This would need to be moved into this crate and depended on by client
129
+ struct WorkflowHandle < WF : Workflow > {
130
+ _d : PhantomData < WF > ,
131
+ }
132
+ struct SignalError ; // just a placeholder
133
+ struct QueryError ; // just a placeholder
134
+
135
+ // The signal/query macros would generate this trait and impl:
136
+ trait MyWorkflowClientExtension {
137
+ fn my_signal ( & self , arg : String ) -> BoxFuture < Result < ( ) , SignalError > > ;
138
+ fn my_query ( & self , arg : String ) -> BoxFuture < Result < Option < u64 > , QueryError > > ;
139
+ }
140
+ impl MyWorkflowClientExtension for WorkflowHandle < MyWorkflow > {
141
+ fn my_signal ( & self , arg : String ) -> BoxFuture < Result < ( ) , SignalError > > {
142
+ // Is actually something like:
143
+ // self.signal("my_signal", arg.serialize())
144
+ todo ! ( )
145
+ }
146
+
147
+ fn my_query ( & self , arg : String ) -> BoxFuture < Result < Option < u64 > , QueryError > > {
148
+ todo ! ( )
149
+ }
150
+ }
151
+
152
+ async fn client_example ( ) {
153
+ // Now you can use the client like:
154
+ // (actually comes from client.start() or client.get_handle() etc)
155
+ let wfh = WorkflowHandle {
156
+ _d : PhantomData :: < MyWorkflow > ,
157
+ } ;
158
+ let _ = wfh. my_signal ( "hi!" . to_string ( ) ) . await ;
159
+ }
126
160
}
0 commit comments