mirror of
https://github.com/gorules/zen.git
synced 2026-10-04 16:02:18 +00:00
feat: serverless examples (#11)
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import json
|
||||
import zen
|
||||
import boto3
|
||||
import os
|
||||
|
||||
s3_client = boto3.client("s3")
|
||||
BUCKET_NAME = os.environ["BUCKET_NAME"]
|
||||
|
||||
def loader(key):
|
||||
file_content = s3_client.get_object(
|
||||
Bucket=BUCKET_NAME, Key=key)["Body"].read().decode("ascii")
|
||||
return file_content
|
||||
|
||||
def lambda_handler(event, context):
|
||||
engine = zen.ZenEngine({"loader": loader})
|
||||
decision = engine.get_decision(event["key"])
|
||||
result = decision.evaluate(event["context"])
|
||||
return {
|
||||
"statusCode": 200,
|
||||
"body": result
|
||||
}
|
||||
Reference in New Issue
Block a user