-
Notifications
You must be signed in to change notification settings - Fork 218
Open
Description
otherwise need to add monkey patch, like (copy from google advice and tested it worked)
# in engine.py file
import orjson # add this
import json
import copy
import durable_rules_engine
from . import logger
# 1. Define a wrapper because orjson returns bytes, but durable-rules needs strings
def orjson_dumps_wrapper(obj, **kwargs):
# Durable-rules may pass arguments like 'ensure_ascii' which orjson doesn't use
return orjson.dumps(obj).decode('utf-8')
def orjson_loads_wrapper(s, **kwargs):
return orjson.loads(s)
# 2. Monkey-patch the standard json module used by durable-rules
# This must be done BEFORE importing or using durable-rules functions
json.dumps = orjson_dumps_wrapper
json.loads = orjson_loads_wrapper
def _unix_now():
dt = datetime.datetime.now()
.......is is possible to add an engine support to couple the json dependency by adding injection setting.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels