forked from votrongdao/FlowX
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBulkJobFlows.cs
More file actions
78 lines (69 loc) · 2.9 KB
/
Copy pathBulkJobFlows.cs
File metadata and controls
78 lines (69 loc) · 2.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
using FlowX;
namespace Crm;
/// <summary>Submits rows to be imported.</summary>
/// <remarks>
/// <strong>Durable, because a submission that is lost is work a caller believes is queued.</strong>
/// The routes that read a job are ephemeral for the opposite reason: a client polls them.
/// </remarks>
[Flow("crm.bulk.import", Version = "1.0.0", Profile = ExecutionProfile.Durable, Owner = "crm-platform")]
[FlowDeadline("PT30S")]
[HttpTrigger("POST", "/api/v1/crm/bulk/imports", Idempotent = true)]
public sealed partial class SubmitImportFlow : Flow<SubmitImport, JobSubmitted>
{
/// <inheritdoc />
protected override void Define(IFlowBuilder<SubmitImport, JobSubmitted> flow)
{
ArgumentNullException.ThrowIfNull(flow);
flow
.Step<SubmitBulkJob, SubmitJob>(
ctx => new SubmitJob(ctx.Input, null, CustomFieldPolicy.Scopes(ctx.Principal)))
.Return(ctx => ctx.Get<JobSubmitted>());
}
}
/// <summary>Submits a request for an object's records as a document.</summary>
[Flow("crm.bulk.export", Version = "1.0.0", Profile = ExecutionProfile.Durable, Owner = "crm-platform")]
[FlowDeadline("PT30S")]
[HttpTrigger("POST", "/api/v1/crm/bulk/exports", Idempotent = true)]
public sealed partial class SubmitExportFlow : Flow<SubmitExport, JobSubmitted>
{
/// <inheritdoc />
protected override void Define(IFlowBuilder<SubmitExport, JobSubmitted> flow)
{
ArgumentNullException.ThrowIfNull(flow);
flow
.Step<SubmitBulkJob, SubmitJob>(
ctx => new SubmitJob(null, ctx.Input, CustomFieldPolicy.Scopes(ctx.Principal)))
.Return(ctx => ctx.Get<JobSubmitted>());
}
}
/// <summary>Tells a caller how their job is getting on.</summary>
[Flow("crm.bulk.status", Version = "1.0.0", Profile = ExecutionProfile.Ephemeral, Owner = "crm-platform")]
[FlowDeadline("PT15S")]
[HttpTrigger("POST", "/api/v1/crm/bulk/jobs")]
public sealed partial class ReadJobFlow : Flow<ReadJob, JobStatus>
{
/// <inheritdoc />
protected override void Define(IFlowBuilder<ReadJob, JobStatus> flow)
{
ArgumentNullException.ThrowIfNull(flow);
flow
.Step<ReadBulkJob, ReadJobFor>(
ctx => new ReadJobFor(ctx.Input, CustomFieldPolicy.Scopes(ctx.Principal)))
.Return(ctx => ctx.Get<JobStatus>());
}
}
/// <summary>Advances one job by one chunk, per tenant, every minute.</summary>
[Flow("crm.bulk.sweep", Version = "1.0.0", Profile = ExecutionProfile.Durable, Owner = "crm-platform")]
[FlowDeadline("PT60S")]
[CronTrigger("* * * * *", PerTenant = true)]
public sealed partial class SweepJobsFlow : Flow<ScheduledFire, JobsSwept>
{
/// <inheritdoc />
protected override void Define(IFlowBuilder<ScheduledFire, JobsSwept> flow)
{
ArgumentNullException.ThrowIfNull(flow);
flow
.Step<SweepBulkJobs>()
.Return(ctx => ctx.Get<JobsSwept>());
}
}