-
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
e0412df
commit 4b1bea7
Showing
13 changed files
with
118 additions
and
108 deletions.
There are no files selected for viewing
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 @@ | ||
import { InvocationContext } from '@azure/functions'; | ||
import { PredicateAndPage } from '../model'; | ||
|
||
async function getConsolidations(input: PredicateAndPage, context: InvocationContext) { | ||
// Do some stuff | ||
context.log('GetConsolidations', JSON.stringify(input)); | ||
return [ | ||
{ orderId: '53rs2', caseId: '071-23-012345' }, | ||
{ orderId: '426gh', caseId: '071-23-43215' }, | ||
]; | ||
} | ||
|
||
export default { | ||
handler: getConsolidations, | ||
}; |
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,12 @@ | ||
import { InvocationContext } from '@azure/functions'; | ||
import { PredicateAndPage } from '../model'; | ||
|
||
async function getPageCount(input: PredicateAndPage, context: InvocationContext) { | ||
// Do some stuff | ||
context.log('#################GetPageCount', JSON.stringify(input)); | ||
return 4; | ||
} | ||
|
||
export default { | ||
handler: getPageCount, | ||
}; |
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
11 changes: 3 additions & 8 deletions
11
backend/functions/poc/dfClient.function.ts → ...functions/poc/client/dfClient.function.ts
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 |
---|---|---|
@@ -1,23 +1,18 @@ | ||
import * as df from 'durable-functions'; | ||
import { app, HttpRequest, HttpResponse, InvocationContext } from '@azure/functions'; | ||
import { HttpRequest, HttpResponse, InvocationContext } from '@azure/functions'; | ||
import { MAIN_ORCHESTRATOR } from '../loadConsolidations'; | ||
|
||
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', { | ||
const instanceId: string = await client.startNew(MAIN_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 was deleted.
Oops, something went wrong.
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import * as df from 'durable-functions'; | ||
import { app } from '@azure/functions'; | ||
|
||
import httpStart from './client/dfClient.function'; | ||
import { main } from './orchestration/orchestrator'; | ||
import { subOrchestratorETL } from './orchestration/sub-orchestrator-etl'; | ||
import { subOrchestratorPaging } from './orchestration/sub-orchestrator-paging'; | ||
import getConsolidations from './activity/getConsolidations'; | ||
import getPageCount from './activity/getPageCount'; | ||
import transformAndLoad from './activity/transformAndLoad'; | ||
|
||
export const SUB_ORCHESTRATOR_ETL = 'SubOrchestratorETL'; | ||
export const SUB_ORCHESTRATOR_PAGING = 'SubOrchestratorPaging'; | ||
export const MAIN_ORCHESTRATOR = 'orchestrator'; | ||
export const PAGE_COUNT_ACTIVITY = 'getPageCountFromACMS'; | ||
export const CONSOLIDATIONS_FROM_ACMS = 'getConsolidationsFromACMS'; | ||
export const TRANSFORM_AND_LOAD = 'transformAndLoad'; | ||
|
||
df.app.orchestration(MAIN_ORCHESTRATOR, main); | ||
df.app.orchestration(SUB_ORCHESTRATOR_ETL, subOrchestratorETL); | ||
df.app.orchestration(SUB_ORCHESTRATOR_PAGING, subOrchestratorPaging); | ||
df.app.activity(CONSOLIDATIONS_FROM_ACMS, getConsolidations); | ||
df.app.activity(PAGE_COUNT_ACTIVITY, getPageCount); | ||
df.app.activity(TRANSFORM_AND_LOAD, transformAndLoad); | ||
|
||
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
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
23 changes: 23 additions & 0 deletions
23
backend/functions/poc/orchestration/sub-orchestrator-etl.ts
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 { CONSOLIDATIONS_FROM_ACMS, TRANSFORM_AND_LOAD } from '../loadConsolidations'; | ||
import { PredicateAndPage } from '../model'; | ||
import { OrchestrationContext } from 'durable-functions'; | ||
|
||
export function* subOrchestratorETL(context: OrchestrationContext) { | ||
const predicateAndPage: PredicateAndPage = context.df.getInput(); | ||
|
||
const consolidatedOrdersPage = yield context.df.callActivity( | ||
CONSOLIDATIONS_FROM_ACMS, | ||
predicateAndPage, | ||
); | ||
|
||
const parallelTasks = []; | ||
for (let i = 0; i < consolidatedOrdersPage.length; i++) { | ||
parallelTasks.push(context.df.callActivity(TRANSFORM_AND_LOAD, 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); | ||
} |
22 changes: 22 additions & 0 deletions
22
backend/functions/poc/orchestration/sub-orchestrator-paging.ts
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,22 @@ | ||
import { Predicate, PredicateAndPage } from '../model'; | ||
import { OrchestrationContext } from 'durable-functions'; | ||
import { PAGE_COUNT_ACTIVITY, SUB_ORCHESTRATOR_ETL } from '../loadConsolidations'; | ||
|
||
export function* subOrchestratorPaging(context: OrchestrationContext) { | ||
const predicate: Predicate = context.df.getInput(); | ||
|
||
const pageCount = yield context.df.callActivity(PAGE_COUNT_ACTIVITY, 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(SUB_ORCHESTRATOR_ETL, predicateAndPage, child_id), | ||
); | ||
} | ||
|
||
yield context.df.Task.all(provisioningTasks); | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.