Skip to content

Commit

Permalink
Also test sched2close timeout & add .net
Browse files Browse the repository at this point in the history
  • Loading branch information
Sushisource committed Feb 22, 2024
1 parent 948553f commit 82c38dd
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 4 deletions.
54 changes: 54 additions & 0 deletions features/activity/basic_no_workflow_timeout/feature.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
namespace activity.basic_no_workflow_timeout;

using Temporalio.Activities;
using Temporalio.Client;
using Temporalio.Exceptions;
using Temporalio.Features.Harness;
using Temporalio.Worker;
using Temporalio.Workflows;

class Feature : IFeature
{
public void ConfigureWorker(Runner runner, TemporalWorkerOptions options) =>
options.AddWorkflow<MyWorkflow>().AddAllActivities(new MyActivities(runner.Client));

[Workflow]
class MyWorkflow
{
private string? activityResult;

[WorkflowRun]
public async Task RunAsync()
{
await Workflow.ExecuteActivityAsync(
(MyActivities act) => act.Echo(),
new()
{
ScheduleToCloseTimeout = TimeSpan.FromMinutes(1)
});

await Workflow.ExecuteActivityAsync(
(MyActivities act) => act.Echo(),
new()
{
StartToCloseTimeout = TimeSpan.FromMinutes(1)
});
}

[WorkflowSignal]
public async Task SetActivityResultAsync(string res) => activityResult = res;
}

class MyActivities
{
private readonly ITemporalClient client;

public MyActivities(ITemporalClient client) => this.client = client;

[Activity]
public async Task<string> Echo()
{
return "hi";
}
}
}
10 changes: 8 additions & 2 deletions features/activity/basic_no_workflow_timeout/feature.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,20 @@ var Feature = harness.Feature{
}

func Workflow(ctx workflow.Context) (string, error) {
// Allow 4 retries with no backoff
ctx = workflow.WithActivityOptions(ctx, workflow.ActivityOptions{
StartToCloseTimeout: 1 * time.Minute,
})

// Execute activity and return error
var result string
err := workflow.ExecuteActivity(ctx, Echo).Get(ctx, &result)
if err != nil {
return "", err
}

ctx = workflow.WithActivityOptions(ctx, workflow.ActivityOptions{
ScheduleToCloseTimeout: 1 * time.Minute,
})
err = workflow.ExecuteActivity(ctx, Echo).Get(ctx, &result)
return result, err
}

Expand Down
8 changes: 6 additions & 2 deletions features/activity/basic_no_workflow_timeout/feature.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,17 @@ public interface feature extends Feature, SimpleWorkflow {
class Impl implements feature {
@Override
public void workflow() {
// Allow 4 retries with no backoff
var activities =
activities(
feature.class, builder -> builder.setStartToCloseTimeout(Duration.ofMinutes(1)));

// Execute activity
activities.echo();

var activitiesSched2Close =
activities(
feature.class, builder -> builder.setScheduleToCloseTimeout(Duration.ofMinutes(1)));

activitiesSched2Close.echo();
}

@Override
Expand Down
4 changes: 4 additions & 0 deletions features/activity/basic_no_workflow_timeout/feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
class Workflow:
@workflow.run
async def run(self) -> str:
await workflow.execute_activity(
echo,
schedule_to_close_timeout=timedelta(minutes=1),
)
return await workflow.execute_activity(
echo,
start_to_close_timeout=timedelta(minutes=1),
Expand Down
4 changes: 4 additions & 0 deletions features/activity/basic_no_workflow_timeout/feature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@ import * as wf from '@temporalio/workflow';
const activities = wf.proxyActivities<typeof activitiesImpl>({
startToCloseTimeout: '1 minute',
});
const activitiesSched2Close = wf.proxyActivities<typeof activitiesImpl>({
scheduleToCloseTimeout: '1 minute',
});

export async function workflow(): Promise<string> {
await activitiesSched2Close.echo('hello');
return await activities.echo('hello');
}

Expand Down

0 comments on commit 82c38dd

Please sign in to comment.