-
-
Notifications
You must be signed in to change notification settings - Fork 643
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(runtime): add __init__ hook in runtime (#1081)
- Loading branch information
Showing
7 changed files
with
43 additions
and
8,898 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 |
---|---|---|
|
@@ -35,8 +35,6 @@ | |
"buildah", | ||
"buildx", | ||
"Builtins", | ||
"casbin", | ||
"casdoor", | ||
"chakra", | ||
"Chakra", | ||
"chatgpt", | ||
|
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
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,41 @@ | ||
import { CLOUD_FUNCTION_COLLECTION, INIT_FUNCTION_NAME } from '../constants' | ||
import { DatabaseAgent } from '../db' | ||
import { CloudFunction, ICloudFunctionData } from './function-engine' | ||
import { logger } from './logger' | ||
import { generateUUID } from './utils' | ||
|
||
/** | ||
* Init hook for `__init__` cloud function | ||
*/ | ||
export class InitHook { | ||
static async invoke() { | ||
const func = await this.getInitCloudFunction() | ||
if (!func) { | ||
return | ||
} | ||
|
||
const cf = new CloudFunction(func) | ||
await cf.invoke({ | ||
method: 'INIT', | ||
requestId: generateUUID(), | ||
__function_name: func.name, | ||
}) | ||
|
||
logger.info('Init hook invoked') | ||
} | ||
|
||
/** | ||
* Get init hook cloud function | ||
* @returns | ||
*/ | ||
private static async getInitCloudFunction() { | ||
const db = DatabaseAgent.db | ||
const doc = await db | ||
.collection<ICloudFunctionData>(CLOUD_FUNCTION_COLLECTION) | ||
.findOne({ | ||
name: INIT_FUNCTION_NAME, | ||
}) | ||
|
||
return doc | ||
} | ||
} |
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
Oops, something went wrong.