-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Jira ticket: CAMS-461 Co-authored-by: Fritz Madden <[email protected]> Co-authored-by: James Brooks <[email protected]> Co-authored-by: Brian Posey <[email protected]>,
- Loading branch information
1 parent
7eb3735
commit bb8a3e5
Showing
9 changed files
with
232 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import * as df from 'durable-functions'; | ||
import { app, HttpRequest, HttpResponse, InvocationContext } from '@azure/functions'; | ||
|
||
export default async function httpStart( | ||
request: HttpRequest, | ||
context: InvocationContext, | ||
): Promise<HttpResponse> { | ||
const client = df.getClient(context); | ||
const body: unknown = await request.json(); | ||
const instanceId: string = await client.startNew('orchestrator', { | ||
input: body, | ||
}); | ||
|
||
context.log(`Started orchestration with ID = '${instanceId}'.`); | ||
|
||
return client.createCheckStatusResponse(request, instanceId); | ||
} | ||
|
||
app.http('dfClient', { | ||
route: 'orchestrators/orchestrator', | ||
extraInputs: [df.input.durableClient()], | ||
handler: httpStart, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import * as df from 'durable-functions'; | ||
import { InvocationContext } from '@azure/functions'; | ||
import { PredicateAndPage } from './model'; | ||
|
||
export default async function handler(input: PredicateAndPage, context: InvocationContext) { | ||
// Do some stuff | ||
context.log('GetConsolidations', JSON.stringify(input)); | ||
} | ||
|
||
df.app.activity('getConsolidationsFromACMS', { | ||
// extraOutputs: [blobOutput], | ||
handler, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import * as df from 'durable-functions'; | ||
import { InvocationContext } from '@azure/functions'; | ||
import { PredicateAndPage } from './model'; | ||
|
||
export default async function handler(input: PredicateAndPage, context: InvocationContext) { | ||
// Do some stuff | ||
context.log('GetPageCount', JSON.stringify(input)); | ||
return 4; | ||
} | ||
|
||
df.app.activity('getPageCountFromACMS', { | ||
handler, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
export type Bounds = { | ||
divisionCodes: string[]; | ||
chapters: string[]; | ||
dateRange: [string, string]; | ||
}; | ||
|
||
export type Predicate = { | ||
divisionCode: string; | ||
chapter: string; | ||
dateRange: [string, string]; | ||
}; | ||
|
||
export type PredicateAndPage = Predicate & { | ||
pageNumber: number; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { Bounds } from './model'; | ||
|
||
import * as df from 'durable-functions'; | ||
|
||
df.app.orchestration('orchestrator', function* (context) { | ||
const bounds: Bounds = context.df.getInput(); | ||
|
||
context.log('orchestrator', JSON.stringify(bounds)); | ||
|
||
const provisioningTasks = []; | ||
|
||
const { divisionCodes, chapters, dateRange } = bounds; | ||
for (const divisionCode of divisionCodes) { | ||
for (const chapter of chapters) { | ||
const predicate = { | ||
divisionCode, | ||
chapter, | ||
dateRange, | ||
}; | ||
const child_id = context.df.instanceId + `:${divisionCode}:${chapter}:`; | ||
provisioningTasks.push( | ||
context.df.callSubOrchestrator('subOrchestrator', predicate, child_id), | ||
); | ||
} | ||
} | ||
yield context.df.Task.all(provisioningTasks); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { PredicateAndPage } from './model'; | ||
|
||
import * as df from 'durable-functions'; | ||
|
||
df.app.orchestration('subOrchestratorETL', function* (context) { | ||
const predicateAndPage: PredicateAndPage = context.df.getInput(); | ||
|
||
context.log('subOrchestratorETL', JSON.stringify(predicateAndPage)); | ||
|
||
const consolidatedOrdersPage = yield context.df.callActivity( | ||
'getConsolidationsFromACMS', | ||
predicateAndPage, | ||
); | ||
|
||
const parallelTasks = []; | ||
for (let i = 0; i < consolidatedOrdersPage.length; i++) { | ||
parallelTasks.push(context.df.callActivity('transformAndLoad', consolidatedOrdersPage[i])); | ||
} | ||
|
||
yield context.df.Task.all(parallelTasks); | ||
|
||
// DO we need to fan in?? | ||
// const sum = parallelTasks.reduce((prev, curr) => prev + curr, 0); | ||
// yield context.df.callActivity('finalResults??', sum); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { Predicate, PredicateAndPage } from './model'; | ||
|
||
import * as df from 'durable-functions'; | ||
|
||
df.app.orchestration('subOrchestratorPaging', function* (context) { | ||
const predicate: Predicate = context.df.getInput(); | ||
|
||
context.log('subOrchestratorPaging', JSON.stringify(predicate)); | ||
|
||
const pageCount = yield context.df.callActivity('getPageCountFromACMS', predicate); | ||
|
||
const provisioningTasks = []; | ||
for (let pageNumber = 0; pageNumber < pageCount; pageNumber++) { | ||
const predicateAndPage: PredicateAndPage = { | ||
...predicate, | ||
pageNumber, | ||
}; | ||
const child_id = context.df.instanceId + `:${pageNumber}`; | ||
provisioningTasks.push( | ||
context.df.callSubOrchestrator('subOrchestrator', predicateAndPage, child_id), | ||
); | ||
} | ||
|
||
yield context.df.Task.all(provisioningTasks); | ||
}); |