Skip to content

Conversation

@vitarb
Copy link
Contributor

@vitarb vitarb commented Feb 4, 2021

This also adds end to end integration test that creates and executes the workflow with a timer.

❯ tctl wf show --wid 2514931016
   1  WorkflowExecutionStarted    {WorkflowType:{Name:test-workflow},                           
                                  ParentInitiatedEventId:0, TaskQueue:{Name:test-tq,            
                                  Kind:Normal}, Input:[], WorkflowTaskTimeout:10s,              
                                  Initiator:Unspecified, LastCompletionResult:[],               
                                  OriginalExecutionRunId:16253121-f432-4b1e-b927-fb77d9d40be6,  
                                  FirstExecutionRunId:16253121-f432-4b1e-b927-fb77d9d40be6,     
                                  Attempt:1, FirstWorkflowTaskBackoff:0s}                       
   2  WorkflowTaskScheduled       {TaskQueue:{Name:test-tq,                                     
                                  Kind:Normal},                                                 
                                  StartToCloseTimeout:10s,                                      
                                  Attempt:1}                                                    
   3  WorkflowTaskStarted         {ScheduledEventId:2, Identity:none,                           
                                  RequestId:82f14b88-46c8-422c-8f30-e4e992fab169}               
   4  WorkflowTaskCompleted       {ScheduledEventId:2,                                          
                                  StartedEventId:3,                                             
                                  Identity:none}                                                
   5  TimerStarted                {TimerId:1432063120,                                          
                                  StartToFireTimeout:1s,                                        
                                  WorkflowTaskCompletedEventId:4}                               
   6  TimerFired                  {TimerId:1432063120,                                          
                                  StartedEventId:5}                                             
   7  WorkflowTaskScheduled       {TaskQueue:{Name:test-tq,                                     
                                  Kind:Normal},                                                 
                                  StartToCloseTimeout:10s,                                      
                                  Attempt:1}                                                    
   8  WorkflowTaskStarted         {ScheduledEventId:7, Identity:none,                           
                                  RequestId:2cb44e0a-3869-434e-86e4-2ec47e605c5e}               
   9  WorkflowTaskCompleted       {ScheduledEventId:7,                                          
                                  StartedEventId:8,                                             
                                  Identity:none}                                                
  10  WorkflowExecutionCompleted  {Result:[],                                                   
                                  WorkflowTaskCompletedEventId:9}                         

@vitarb vitarb requested a review from Sushisource as a code owner February 4, 2021 05:13
message PollTaskReq {
// If true, poll for workflow tasks
bool workflows = 1;
// If true, poll for activity tasks
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would make it enum to support some future extensions for poll types.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How are you thinking exactly? The enum can only take on one value, so we really need like a bitmask or something but that doesn't exist in protobuf.

Looks like repeated enum works so I can do that


// An instruction to the lang sdk to run some workflow code, whether for the first time or from
// a cached state.
message WFActivation {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to add some fields to validate that the cache is not stale. One option is to pass previousEventId and the lastEventId. Another option is to pass some opaque tokens instead.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mfateev Passing a token seems easier for lang sdk. Can you elaborate on how that might work? I don't want to change it in this PR but I'll make a task for it.

Also this PR is moved to #36 since we were on Vitaly's fork

// An instruction to the lang sdk to run some workflow code, whether for the first time or from
// a cached state.
message WFActivation {
// Time the activation(s) were requested
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment sounds like the system time of the activation.

But it is a workflow time of the activation.

/// language SDK's responsibility to call the appropriate code with the provided inputs.
///
/// TODO: Examples
fn poll_task(&self, task_queue: &str) -> Result<Task>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it mean that we are not supporting core polling on multiple queues and language SDK being single threaded?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be possible, that's the whole reason why we pass it as a parameter as opposed to a field during initialization.

pub trait RespondWorkflowTaskCompletedApi {
/// Fetch new work. Should block indefinitely if there is no work.
async fn get_work(&self, task_queue: &str) -> Result<PollWorkflowTaskQueueResponse>;
async fn complete(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The above comment doesn't make sense anymore.

fn intercept(mut req: Request<()>) -> Result<Request<()>, Status> {
// TODO convert error
let metadata = req.metadata_mut();
metadata.insert("grpc-timeout", "50000m".parse().unwrap());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 50 second timeout applies only to long polls. All other requests should have a much shorter (ideally configurable) one.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are just testing things out at this point, definitely not a final version.

@Sushisource
Copy link
Member

Moved to #36

@Sushisource Sushisource closed this Feb 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants