modmex-lambda 0.5.11__tar.gz → 0.6.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (252) hide show
  1. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/PKG-INFO +56 -1
  2. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/README.md +55 -0
  3. modmex_lambda-0.6.0/modmex_lambda/connectors/eventbridge_scheduler.py +24 -0
  4. modmex_lambda-0.6.0/modmex_lambda/connectors/ieventbridge_scheduler.py +21 -0
  5. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/connectors/module.py +10 -0
  6. modmex_lambda-0.6.0/modmex_lambda/stream/flavors/__init__.py +24 -0
  7. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/stream/flavors/base_flavor.py +15 -0
  8. modmex_lambda-0.6.0/modmex_lambda/stream/flavors/schedule.py +162 -0
  9. modmex_lambda-0.6.0/modmex_lambda/stream/operators/scheduler.py +36 -0
  10. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/stream/runner.py +3 -3
  11. modmex_lambda-0.6.0/modmex_lambda/stream/schedulers.py +15 -0
  12. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/pyproject.toml +1 -1
  13. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/connectors/test_lazy_clients.py +7 -0
  14. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/connectors/test_simple_connectors.py +28 -0
  15. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/stream/flavors/test_base_flavor.py +6 -0
  16. modmex_lambda-0.6.0/tests/stream/flavors/test_schedule.py +171 -0
  17. modmex_lambda-0.6.0/tests/stream/operators/test_scheduler.py +39 -0
  18. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/stream/test_dependency_resolver.py +7 -0
  19. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/stream/test_faults.py +5 -6
  20. modmex_lambda-0.5.11/tests/stream/utils/__init__.py +0 -0
  21. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/.github/workflows/ci.yml +0 -0
  22. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/.github/workflows/release.yml +0 -0
  23. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/.gitignore +0 -0
  24. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/LICENSE +0 -0
  25. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/__init__.py +0 -0
  26. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/connectors/__init__.py +0 -0
  27. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/connectors/cloudwatch.py +0 -0
  28. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/connectors/dynamodb.py +0 -0
  29. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/connectors/eventbridge.py +0 -0
  30. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/connectors/icloudwatch.py +0 -0
  31. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/connectors/idynamodb.py +0 -0
  32. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/connectors/ieventbridge.py +0 -0
  33. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/connectors/ilambda.py +0 -0
  34. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/connectors/is3.py +0 -0
  35. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/connectors/isns.py +0 -0
  36. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/connectors/isqs.py +0 -0
  37. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/connectors/lambda_.py +0 -0
  38. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/connectors/s3.py +0 -0
  39. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/connectors/sns.py +0 -0
  40. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/connectors/sqs.py +0 -0
  41. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/data_classes/__init__.py +0 -0
  42. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/data_classes/api_gateway_authorizer_event.py +0 -0
  43. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/data_classes/api_gateway_proxy_event.py +0 -0
  44. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/data_classes/api_gateway_websocket_event.py +0 -0
  45. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/data_classes/cognito_user_pool_event.py +0 -0
  46. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/data_classes/common.py +0 -0
  47. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/dependencies.py +0 -0
  48. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/event_handler/__init__.py +0 -0
  49. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/event_handler/api_gateway.py +0 -0
  50. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/event_handler/constants.py +0 -0
  51. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/event_handler/content_types.py +0 -0
  52. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/event_handler/cors.py +0 -0
  53. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/event_handler/dependencies/__init__.py +0 -0
  54. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/event_handler/dependencies/compat.py +0 -0
  55. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/event_handler/dependencies/dependant.py +0 -0
  56. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/event_handler/dependencies/dependency_middleware.py +0 -0
  57. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/event_handler/dependencies/depends.py +0 -0
  58. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/event_handler/dependencies/params.py +0 -0
  59. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/event_handler/dependencies/types.py +0 -0
  60. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/event_handler/exception_handler.py +0 -0
  61. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/event_handler/exceptions.py +0 -0
  62. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/event_handler/gateway_response.py +0 -0
  63. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/event_handler/middlewares.py +0 -0
  64. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/event_handler/params.py +0 -0
  65. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/event_handler/request.py +0 -0
  66. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/event_handler/response.py +0 -0
  67. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/event_handler/routing.py +0 -0
  68. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/event_handler/routing_fallbacks.py +0 -0
  69. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/event_handler/types.py +0 -0
  70. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/event_sources.py +0 -0
  71. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/exceptions.py +0 -0
  72. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/logging.py +0 -0
  73. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/params.py +0 -0
  74. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/parser.py +0 -0
  75. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/persistence/__init__.py +0 -0
  76. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/persistence/dynamodb/__init__.py +0 -0
  77. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/persistence/dynamodb/expressions.py +0 -0
  78. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/persistence/dynamodb/keys.py +0 -0
  79. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/persistence/dynamodb/materialized_views.py +0 -0
  80. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/persistence/dynamodb/stream_fields.py +0 -0
  81. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/py.typed +0 -0
  82. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/request.py +0 -0
  83. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/resolver.py +0 -0
  84. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/response.py +0 -0
  85. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/routing.py +0 -0
  86. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/shared/__init__.py +0 -0
  87. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/shared/cookies.py +0 -0
  88. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/shared/headers_serializer.py +0 -0
  89. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/shared/json_encoder.py +0 -0
  90. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/shared/types.py +0 -0
  91. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/stream/__init__.py +0 -0
  92. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/stream/events/__init__.py +0 -0
  93. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/stream/events/dynamodb.py +0 -0
  94. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/stream/events/kinesis.py +0 -0
  95. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/stream/events/s3.py +0 -0
  96. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/stream/events/sns.py +0 -0
  97. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/stream/events/sqs.py +0 -0
  98. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/stream/filters/__init__.py +0 -0
  99. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/stream/filters/content.py +0 -0
  100. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/stream/filters/event_type.py +0 -0
  101. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/stream/filters/latch.py +0 -0
  102. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/stream/filters/skip.py +0 -0
  103. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/stream/flavors/cdc.py +0 -0
  104. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/stream/flavors/collect.py +0 -0
  105. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/stream/flavors/correlate.py +0 -0
  106. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/stream/flavors/evaluate.py +0 -0
  107. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/stream/flavors/expired.py +0 -0
  108. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/stream/flavors/iflavor.py +0 -0
  109. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/stream/flavors/job.py +0 -0
  110. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/stream/flavors/materialize.py +0 -0
  111. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/stream/flavors/s3.py +0 -0
  112. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/stream/flavors/sns.py +0 -0
  113. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/stream/flavors/task.py +0 -0
  114. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/stream/flavors/update.py +0 -0
  115. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/stream/irules_registry.py +0 -0
  116. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/stream/operators/__init__.py +0 -0
  117. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/stream/operators/cloudwatch.py +0 -0
  118. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/stream/operators/dynamodb.py +0 -0
  119. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/stream/operators/ioperator.py +0 -0
  120. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/stream/operators/lambda_.py +0 -0
  121. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/stream/operators/publisher.py +0 -0
  122. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/stream/operators/s3.py +0 -0
  123. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/stream/operators/sns.py +0 -0
  124. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/stream/operators/sqs.py +0 -0
  125. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/stream/rules_registry.py +0 -0
  126. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/stream/sources/__init__.py +0 -0
  127. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/stream/sources/base.py +0 -0
  128. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/stream/sources/dynamodb.py +0 -0
  129. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/stream/sources/kinesis.py +0 -0
  130. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/stream/sources/s3.py +0 -0
  131. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/stream/sources/sns.py +0 -0
  132. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/stream/sources/sqs.py +0 -0
  133. {modmex_lambda-0.5.11/modmex_lambda/stream/flavors → modmex_lambda-0.6.0/modmex_lambda/stream/utils}/__init__.py +0 -0
  134. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/stream/utils/apigateway.py +0 -0
  135. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/stream/utils/aws.py +0 -0
  136. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/stream/utils/batch.py +0 -0
  137. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/stream/utils/cloudwatch.py +0 -0
  138. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/stream/utils/concurrency.py +0 -0
  139. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/stream/utils/contracts.py +0 -0
  140. {modmex_lambda-0.5.11/modmex_lambda/stream/utils → modmex_lambda-0.6.0/modmex_lambda/stream/utils/data_classes}/__init__.py +0 -0
  141. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/stream/utils/data_classes/dynamodb.py +0 -0
  142. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/stream/utils/decorators.py +0 -0
  143. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/stream/utils/dynamodb.py +0 -0
  144. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/stream/utils/eventbridge.py +0 -0
  145. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/stream/utils/faults.py +0 -0
  146. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/stream/utils/filters.py +0 -0
  147. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/stream/utils/json_encoder.py +0 -0
  148. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/stream/utils/lambda_.py +0 -0
  149. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/stream/utils/operators.py +0 -0
  150. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/stream/utils/pluralize.py +0 -0
  151. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/stream/utils/print.py +0 -0
  152. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/stream/utils/retry.py +0 -0
  153. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/stream/utils/s3.py +0 -0
  154. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/stream/utils/sns.py +0 -0
  155. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/stream/utils/split.py +0 -0
  156. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/stream/utils/sqs.py +0 -0
  157. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/stream/utils/tags.py +0 -0
  158. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/stream/utils/time.py +0 -0
  159. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/stream/utils/uow.py +0 -0
  160. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/tracing.py +0 -0
  161. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/modmex_lambda/validation.py +0 -0
  162. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/poetry.lock +0 -0
  163. {modmex_lambda-0.5.11/modmex_lambda/stream/utils/data_classes → modmex_lambda-0.6.0/tests}/__init__.py +0 -0
  164. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/conftest.py +0 -0
  165. {modmex_lambda-0.5.11/tests → modmex_lambda-0.6.0/tests/connectors}/__init__.py +0 -0
  166. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/connectors/conftest.py +0 -0
  167. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/connectors/test_cloudwatch.py +0 -0
  168. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/connectors/test_dynamodb.py +0 -0
  169. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/connectors/test_s3.py +0 -0
  170. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/connectors/test_sns.py +0 -0
  171. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/connectors/test_sqs.py +0 -0
  172. {modmex_lambda-0.5.11/tests/connectors → modmex_lambda-0.6.0/tests/data_classes}/__init__.py +0 -0
  173. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/data_classes/test_api_gateway_proxy_event.py +0 -0
  174. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/data_classes/test_cognito_user_pool_event.py +0 -0
  175. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/data_classes/test_common.py +0 -0
  176. {modmex_lambda-0.5.11/tests/data_classes → modmex_lambda-0.6.0/tests/event_handler}/__init__.py +0 -0
  177. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/event_handler/test_api_gateway.py +0 -0
  178. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/event_handler/test_cors.py +0 -0
  179. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/event_handler/test_dependencies.py +0 -0
  180. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/event_handler/test_exception_handler.py +0 -0
  181. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/event_handler/test_gateway_response.py +0 -0
  182. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/event_handler/test_request.py +0 -0
  183. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/event_handler/test_response.py +0 -0
  184. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/event_handler/test_routing.py +0 -0
  185. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/persistence/__init__.py +0 -0
  186. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/persistence/test_dynamodb_expressions.py +0 -0
  187. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/persistence/test_dynamodb_keys.py +0 -0
  188. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/persistence/test_dynamodb_materialized_views.py +0 -0
  189. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/persistence/test_dynamodb_stream_fields.py +0 -0
  190. {modmex_lambda-0.5.11/tests/event_handler → modmex_lambda-0.6.0/tests/shared}/__init__.py +0 -0
  191. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/shared/test_cookies_headers.py +0 -0
  192. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/shared/test_json_encoder.py +0 -0
  193. {modmex_lambda-0.5.11/tests/shared → modmex_lambda-0.6.0/tests/stream}/__init__.py +0 -0
  194. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/stream/conftest.py +0 -0
  195. {modmex_lambda-0.5.11/tests/stream → modmex_lambda-0.6.0/tests/stream/events}/__init__.py +0 -0
  196. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/stream/events/test_dynamodb.py +0 -0
  197. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/stream/events/test_kinesis.py +0 -0
  198. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/stream/events/test_s3.py +0 -0
  199. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/stream/events/test_sns.py +0 -0
  200. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/stream/events/test_sqs.py +0 -0
  201. {modmex_lambda-0.5.11/tests/stream/events → modmex_lambda-0.6.0/tests/stream/filters}/__init__.py +0 -0
  202. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/stream/filters/test_content.py +0 -0
  203. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/stream/filters/test_event_type.py +0 -0
  204. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/stream/filters/test_latch.py +0 -0
  205. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/stream/filters/test_skip.py +0 -0
  206. {modmex_lambda-0.5.11/tests/stream/filters → modmex_lambda-0.6.0/tests/stream/flavors}/__init__.py +0 -0
  207. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/stream/flavors/source_events.py +0 -0
  208. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/stream/flavors/test_cdc.py +0 -0
  209. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/stream/flavors/test_collect.py +0 -0
  210. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/stream/flavors/test_correlate.py +0 -0
  211. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/stream/flavors/test_evaluate.py +0 -0
  212. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/stream/flavors/test_expired.py +0 -0
  213. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/stream/flavors/test_job.py +0 -0
  214. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/stream/flavors/test_materialize.py +0 -0
  215. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/stream/flavors/test_s3.py +0 -0
  216. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/stream/flavors/test_sns.py +0 -0
  217. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/stream/flavors/test_task.py +0 -0
  218. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/stream/flavors/test_update.py +0 -0
  219. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/stream/test_rules_registry.py +0 -0
  220. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/stream/test_runner.py +0 -0
  221. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/stream/test_runner_pipeline.py +0 -0
  222. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/stream/test_sources.py +0 -0
  223. {modmex_lambda-0.5.11/tests/stream/flavors → modmex_lambda-0.6.0/tests/stream/utils}/__init__.py +0 -0
  224. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/stream/utils/faults.py +0 -0
  225. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/stream/utils/test_apigateway.py +0 -0
  226. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/stream/utils/test_aws.py +0 -0
  227. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/stream/utils/test_batch.py +0 -0
  228. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/stream/utils/test_cloudwatch.py +0 -0
  229. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/stream/utils/test_concurrency.py +0 -0
  230. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/stream/utils/test_decorators.py +0 -0
  231. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/stream/utils/test_dynamodb.py +0 -0
  232. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/stream/utils/test_eventbridge.py +0 -0
  233. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/stream/utils/test_filters.py +0 -0
  234. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/stream/utils/test_json_encoder.py +0 -0
  235. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/stream/utils/test_lambda.py +0 -0
  236. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/stream/utils/test_operators.py +0 -0
  237. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/stream/utils/test_pluralize.py +0 -0
  238. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/stream/utils/test_print.py +0 -0
  239. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/stream/utils/test_retry.py +0 -0
  240. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/stream/utils/test_s3.py +0 -0
  241. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/stream/utils/test_sns.py +0 -0
  242. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/stream/utils/test_split.py +0 -0
  243. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/stream/utils/test_sqs.py +0 -0
  244. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/stream/utils/test_tags.py +0 -0
  245. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/stream/utils/test_time.py +0 -0
  246. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/stream/utils/test_uow.py +0 -0
  247. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/test_lazy_imports.py +0 -0
  248. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/test_logging.py +0 -0
  249. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/test_parser_event_sources.py +0 -0
  250. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/test_reexports.py +0 -0
  251. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/test_tracing.py +0 -0
  252. {modmex_lambda-0.5.11 → modmex_lambda-0.6.0}/tests/test_validation.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: modmex-lambda
3
- Version: 0.5.11
3
+ Version: 0.6.0
4
4
  Summary: Ultra-lightweight AWS Lambda utilities for API Gateway routing and event handling.
5
5
  Author: Modmex
6
6
  License: MIT
@@ -1135,6 +1135,59 @@ control_registry = (
1135
1135
  handler = DynamoDBSource(control_registry, concurrency=False).handle
1136
1136
  ```
1137
1137
 
1138
+ ### Deferred Domain Events
1139
+
1140
+ Use `Schedule` when a process needs a durable, one-time future event: an
1141
+ approval deadline, a retry window, an SLA check, or reconciliation after a
1142
+ communication ends. It creates an EventBridge Scheduler entry; it does not keep
1143
+ a Lambda invocation waiting.
1144
+
1145
+ ```text
1146
+ domain event -> Schedule -> EventBridge Scheduler -> EventBridge -> listener
1147
+ ```
1148
+
1149
+ The event delivered later uses the same domain-event envelope as every other
1150
+ event. Give the schedule a deterministic name and client token so a duplicate
1151
+ source event represents the same business deadline.
1152
+
1153
+ ```python
1154
+ from modmex_lambda.stream.flavors.schedule import Schedule
1155
+ from modmex_lambda.stream.rules_registry import RulesRegistry
1156
+ from modmex_lambda.stream.sources import KinesisSource
1157
+
1158
+ registry = RulesRegistry().registry(
1159
+ Schedule({
1160
+ "id": "schedule-script-result-deadline",
1161
+ "event_type": "communication-completed",
1162
+ "delay_minutes": 5,
1163
+ "schedule_name": lambda uow: (
1164
+ f"script-result-deadline-{uow['event']['script_run']['id']}"
1165
+ ),
1166
+ "client_token": lambda uow: (
1167
+ f"deadline-{uow['event']['script_run']['id']}"
1168
+ ),
1169
+ "to_event": lambda uow, _schedule, template: {
1170
+ **template,
1171
+ "type": "script_run-result_deadline_reached",
1172
+ "script_run": uow["event"]["script_run"],
1173
+ },
1174
+ })
1175
+ )
1176
+
1177
+ handler = KinesisSource(registry, concurrency=False).handle
1178
+ ```
1179
+
1180
+ Set `BUS_ARN` and `SCHEDULER_ROLE_ARN`, or provide `bus_arn` and
1181
+ `role_arn` in the rule. The Lambda that creates schedules needs Scheduler API
1182
+ permissions; the Scheduler execution role needs `events:PutEvents` on the
1183
+ target bus. `Schedule` uses `ActionAfterCompletion=DELETE`, so AWS removes a
1184
+ one-time schedule after delivery.
1185
+
1186
+ Use `schedule_at` when the deadline is already an explicit, timezone-aware
1187
+ `datetime`. Use `delay_minutes` for the common case of a relative deadline; it
1188
+ is calculated from the source event's millisecond `timestamp`, not from Lambda
1189
+ processing time. Declare exactly one of those fields.
1190
+
1138
1191
  ### Event Hub
1139
1192
 
1140
1193
  EventBridge is a natural hub for domain events. Flavors like
@@ -1154,6 +1207,8 @@ language and should be routed by event type, source, account, or bus.
1154
1207
  per-item results.
1155
1208
  - `Expired`: consumes DynamoDB TTL `REMOVE` records and publishes expiration
1156
1209
  events.
1210
+ - `Schedule`: schedules one standard domain event for a future time through
1211
+ EventBridge Scheduler.
1157
1212
  - `S3`: writes objects to S3.
1158
1213
  - `Sns`: publishes messages to SNS.
1159
1214
  - `Update`: queries, gets, and updates DynamoDB records.
@@ -1112,6 +1112,59 @@ control_registry = (
1112
1112
  handler = DynamoDBSource(control_registry, concurrency=False).handle
1113
1113
  ```
1114
1114
 
1115
+ ### Deferred Domain Events
1116
+
1117
+ Use `Schedule` when a process needs a durable, one-time future event: an
1118
+ approval deadline, a retry window, an SLA check, or reconciliation after a
1119
+ communication ends. It creates an EventBridge Scheduler entry; it does not keep
1120
+ a Lambda invocation waiting.
1121
+
1122
+ ```text
1123
+ domain event -> Schedule -> EventBridge Scheduler -> EventBridge -> listener
1124
+ ```
1125
+
1126
+ The event delivered later uses the same domain-event envelope as every other
1127
+ event. Give the schedule a deterministic name and client token so a duplicate
1128
+ source event represents the same business deadline.
1129
+
1130
+ ```python
1131
+ from modmex_lambda.stream.flavors.schedule import Schedule
1132
+ from modmex_lambda.stream.rules_registry import RulesRegistry
1133
+ from modmex_lambda.stream.sources import KinesisSource
1134
+
1135
+ registry = RulesRegistry().registry(
1136
+ Schedule({
1137
+ "id": "schedule-script-result-deadline",
1138
+ "event_type": "communication-completed",
1139
+ "delay_minutes": 5,
1140
+ "schedule_name": lambda uow: (
1141
+ f"script-result-deadline-{uow['event']['script_run']['id']}"
1142
+ ),
1143
+ "client_token": lambda uow: (
1144
+ f"deadline-{uow['event']['script_run']['id']}"
1145
+ ),
1146
+ "to_event": lambda uow, _schedule, template: {
1147
+ **template,
1148
+ "type": "script_run-result_deadline_reached",
1149
+ "script_run": uow["event"]["script_run"],
1150
+ },
1151
+ })
1152
+ )
1153
+
1154
+ handler = KinesisSource(registry, concurrency=False).handle
1155
+ ```
1156
+
1157
+ Set `BUS_ARN` and `SCHEDULER_ROLE_ARN`, or provide `bus_arn` and
1158
+ `role_arn` in the rule. The Lambda that creates schedules needs Scheduler API
1159
+ permissions; the Scheduler execution role needs `events:PutEvents` on the
1160
+ target bus. `Schedule` uses `ActionAfterCompletion=DELETE`, so AWS removes a
1161
+ one-time schedule after delivery.
1162
+
1163
+ Use `schedule_at` when the deadline is already an explicit, timezone-aware
1164
+ `datetime`. Use `delay_minutes` for the common case of a relative deadline; it
1165
+ is calculated from the source event's millisecond `timestamp`, not from Lambda
1166
+ processing time. Declare exactly one of those fields.
1167
+
1115
1168
  ### Event Hub
1116
1169
 
1117
1170
  EventBridge is a natural hub for domain events. Flavors like
@@ -1131,6 +1184,8 @@ language and should be routed by event type, source, account, or bus.
1131
1184
  per-item results.
1132
1185
  - `Expired`: consumes DynamoDB TTL `REMOVE` records and publishes expiration
1133
1186
  events.
1187
+ - `Schedule`: schedules one standard domain event for a future time through
1188
+ EventBridge Scheduler.
1134
1189
  - `S3`: writes objects to S3.
1135
1190
  - `Sns`: publishes messages to SNS.
1136
1191
  - `Update`: queries, gets, and updates DynamoDB records.
@@ -0,0 +1,24 @@
1
+ from modmex_lambda.connectors.ieventbridge_scheduler import (
2
+ IEventBridgeSchedulerConnector,
3
+ )
4
+
5
+
6
+ class Connector(IEventBridgeSchedulerConnector):
7
+ """Lazy adapter for the EventBridge Scheduler API."""
8
+
9
+ def __init__(self, client=None) -> None:
10
+ self._client = client
11
+
12
+ @property
13
+ def client(self):
14
+ if self._client is None:
15
+ import boto3
16
+
17
+ self._client = boto3.client("scheduler")
18
+ return self._client
19
+
20
+ def create_schedule(self, params):
21
+ return self.client.create_schedule(**params)
22
+
23
+ def delete_schedule(self, params):
24
+ return self.client.delete_schedule(**params)
@@ -0,0 +1,21 @@
1
+ from abc import ABC, abstractmethod
2
+ from typing import Any, Dict
3
+
4
+
5
+ class IEventBridgeSchedulerConnector(ABC):
6
+ """Schedules one-time EventBridge deliveries."""
7
+
8
+ @property
9
+ def client(self) -> Any:
10
+ """Returns the EventBridge Scheduler client."""
11
+ raise NotImplementedError("client property must be implemented")
12
+
13
+ @abstractmethod
14
+ def create_schedule(self, params: Dict[str, Any]) -> Dict[str, Any]:
15
+ """Creates a one-time schedule."""
16
+ raise NotImplementedError("create_schedule method must be implemented")
17
+
18
+ @abstractmethod
19
+ def delete_schedule(self, params: Dict[str, Any]) -> Dict[str, Any]:
20
+ """Deletes a previously created schedule."""
21
+ raise NotImplementedError("delete_schedule method must be implemented")
@@ -7,6 +7,9 @@ from injector import Module, provider, singleton
7
7
  from modmex_lambda.connectors.icloudwatch import ICloudWatchConnector
8
8
  from modmex_lambda.connectors.idynamodb import IDynamodbConnector
9
9
  from modmex_lambda.connectors.ieventbridge import IEventBridgeConnector
10
+ from modmex_lambda.connectors.ieventbridge_scheduler import (
11
+ IEventBridgeSchedulerConnector,
12
+ )
10
13
  from modmex_lambda.connectors.ilambda import ILambdaConnector
11
14
  from modmex_lambda.connectors.is3 import IS3Connector
12
15
  from modmex_lambda.connectors.isns import ISNSConnector
@@ -38,6 +41,13 @@ class AwsConnectorsModule(Module):
38
41
 
39
42
  return Connector()
40
43
 
44
+ @singleton
45
+ @provider
46
+ def provide_eventbridge_scheduler(self) -> IEventBridgeSchedulerConnector:
47
+ from modmex_lambda.connectors.eventbridge_scheduler import Connector
48
+
49
+ return Connector()
50
+
41
51
  @singleton
42
52
  @provider
43
53
  def provide_lambda(self) -> ILambdaConnector:
@@ -0,0 +1,24 @@
1
+ from importlib import import_module
2
+ from typing import Any
3
+
4
+ _EXPORTS = {
5
+ "Schedule": ("modmex_lambda.stream.flavors.schedule", "Schedule"),
6
+ "ScheduleRule": ("modmex_lambda.stream.flavors.schedule", "ScheduleRule"),
7
+ }
8
+
9
+ __all__ = list(_EXPORTS)
10
+
11
+
12
+ def __getattr__(name: str) -> Any:
13
+ target = _EXPORTS.get(name)
14
+ if target is None:
15
+ raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
16
+
17
+ module_name, attr = target
18
+ value = getattr(import_module(module_name), attr)
19
+ globals()[name] = value
20
+ return value
21
+
22
+
23
+ def __dir__() -> list[str]:
24
+ return sorted([*globals().keys(), *__all__])
@@ -3,6 +3,9 @@ from typing import TYPE_CHECKING, Any, Generic, Optional, Type, TypeVar
3
3
  from modmex_lambda.connectors.icloudwatch import ICloudWatchConnector
4
4
  from modmex_lambda.connectors.idynamodb import IDynamodbConnector
5
5
  from modmex_lambda.connectors.ieventbridge import IEventBridgeConnector
6
+ from modmex_lambda.connectors.ieventbridge_scheduler import (
7
+ IEventBridgeSchedulerConnector,
8
+ )
6
9
  from modmex_lambda.connectors.ilambda import ILambdaConnector
7
10
  from modmex_lambda.connectors.is3 import IS3Connector
8
11
  from modmex_lambda.connectors.isns import ISNSConnector
@@ -24,6 +27,7 @@ if TYPE_CHECKING:
24
27
  from modmex_lambda.stream.operators.s3 import S3Ops
25
28
  from modmex_lambda.stream.operators.sns import SNSOps
26
29
  from modmex_lambda.stream.operators.sqs import SQSOps
30
+ from modmex_lambda.stream.operators.scheduler import SchedulerOps
27
31
 
28
32
 
29
33
  TEvent = TypeVar("TEvent", bound=Event)
@@ -50,6 +54,7 @@ class BaseFlavor(Generic[TEvent], IFlavor):
50
54
  self._s3_ops: Optional["S3Ops"] = None
51
55
  self._sns_ops: Optional["SNSOps"] = None
52
56
  self._sqs_ops: Optional["SQSOps"] = None
57
+ self._scheduler_ops: Optional["SchedulerOps"] = None
53
58
 
54
59
  def bind(self, dependency_resolver: DependencyResolver) -> "BaseFlavor[TEvent]":
55
60
  if self.dependency_resolver is None:
@@ -120,6 +125,16 @@ class BaseFlavor(Generic[TEvent], IFlavor):
120
125
  )
121
126
  return self._sqs_ops
122
127
 
128
+ @property
129
+ def scheduler_ops(self) -> "SchedulerOps":
130
+ if self._scheduler_ops is None:
131
+ from modmex_lambda.stream.operators.scheduler import SchedulerOps
132
+
133
+ self._scheduler_ops = SchedulerOps(
134
+ self.resolve(IEventBridgeSchedulerConnector)
135
+ )
136
+ return self._scheduler_ops
137
+
123
138
  @property
124
139
  def publisher(self) -> Publisher[TEvent]:
125
140
  if self._publisher is None:
@@ -0,0 +1,162 @@
1
+ import json
2
+ import os
3
+ from datetime import datetime, timedelta, timezone
4
+ from typing import Any, Callable, Optional
5
+
6
+ from reactivex import Observable, operators as ops
7
+
8
+ from modmex_lambda.connectors.ieventbridge import IEventBridgeConnector
9
+ from modmex_lambda.dependencies import DependencyResolver
10
+ from modmex_lambda.stream.flavors.base_flavor import BaseFlavor
11
+ from modmex_lambda.stream.operators.publisher import PublisherOptions
12
+ from modmex_lambda.stream.utils.contracts import BaseRule, Event, Uow
13
+ from modmex_lambda.stream.utils.faults import faulty
14
+ from modmex_lambda.stream.utils.filters import on_content, on_event_type
15
+ from modmex_lambda.stream.utils.operators import try_filter, try_map
16
+ from modmex_lambda.stream.utils.print import print_end, print_start
17
+ from modmex_lambda.stream.utils.tags import adorn_standard_tags
18
+
19
+
20
+ class ScheduleRule(BaseRule, total=False):
21
+ """Declares a one-time future delivery of a standard domain event."""
22
+
23
+ schedule_at: Callable[[Uow], datetime]
24
+ delay_minutes: int | Callable[[Uow], int]
25
+ schedule_name: str | Callable[[Uow], str]
26
+ to_event: Callable[[Uow, "Schedule", Event], Event]
27
+ bus_arn: str | Callable[[Uow], str]
28
+ role_arn: str | Callable[[Uow], str]
29
+ group_name: str | Callable[[Uow], str]
30
+ source: str | Callable[[Uow], str]
31
+ client_token: str | Callable[[Uow], str]
32
+
33
+
34
+ class Schedule(BaseFlavor):
35
+ """Schedules a standard domain event for one future point in time."""
36
+
37
+ def __init__(
38
+ self,
39
+ rule: ScheduleRule,
40
+ *,
41
+ logger: Optional[Any] = None,
42
+ connector: Optional[IEventBridgeConnector] = None,
43
+ dependency_resolver: Optional[DependencyResolver] = None,
44
+ publisher_options: Optional[PublisherOptions] = None,
45
+ ) -> None:
46
+ super().__init__(
47
+ logger=logger,
48
+ connector=connector,
49
+ dependency_resolver=dependency_resolver,
50
+ publisher_options=publisher_options,
51
+ )
52
+ self.rule = rule
53
+
54
+ @property
55
+ def id(self):
56
+ return self.rule["id"]
57
+
58
+ def __call__(self, source: Observable):
59
+ return source.pipe(
60
+ try_filter(on_event_type(self.rule)),
61
+ ops.do_action(print_start(self.logger)),
62
+ try_filter(on_content(self.rule)),
63
+ try_map(faulty(self._to_schedule_request)),
64
+ self.scheduler_ops,
65
+ ops.do_action(print_end(self.logger)),
66
+ )
67
+
68
+ def _to_schedule_request(self, uow: Uow) -> Uow:
69
+ schedule_at = self._resolve_schedule_at(uow)
70
+ if schedule_at.tzinfo is None:
71
+ raise ValueError("schedule_at must return a timezone-aware datetime.")
72
+
73
+ scheduled_event = self._to_event(uow, schedule_at)
74
+ bus_arn = self._value(
75
+ "bus_arn", uow, os.getenv("BUS_ARN")
76
+ )
77
+ role_arn = self._value("role_arn", uow, os.getenv("SCHEDULER_ROLE_ARN"))
78
+ if not bus_arn:
79
+ raise ValueError("bus_arn or BUS_ARN is required.")
80
+ if not role_arn:
81
+ raise ValueError("role_arn or SCHEDULER_ROLE_ARN is required.")
82
+ return {
83
+ **uow,
84
+ "scheduled_event": scheduled_event,
85
+ "schedule_request": {
86
+ "Name": self._value("schedule_name", uow),
87
+ "GroupName": self._value("group_name", uow, "default"),
88
+ "ScheduleExpression": self._schedule_expression(schedule_at),
89
+ "FlexibleTimeWindow": {"Mode": "OFF"},
90
+ "ActionAfterCompletion": "DELETE",
91
+ "ClientToken": self._value("client_token", uow, scheduled_event["id"]),
92
+ "Target": {
93
+ "Arn": self._value(
94
+ "bus_arn", uow, bus_arn
95
+ ),
96
+ "RoleArn": self._value(
97
+ "role_arn", uow, role_arn
98
+ ),
99
+ "EventBridgeParameters": {
100
+ "Source": self._value(
101
+ "source", uow, os.getenv("BUS_SRC", "custom")
102
+ ),
103
+ "DetailType": scheduled_event["type"],
104
+ },
105
+ "Input": json.dumps(scheduled_event),
106
+ },
107
+ },
108
+ }
109
+
110
+ def _to_event(self, uow: Uow, schedule_at: datetime) -> Event:
111
+ template: Event = {
112
+ "id": self._value("client_token", uow, self._value("schedule_name", uow)),
113
+ "timestamp": int(schedule_at.timestamp() * 1000),
114
+ "partition_key": uow["event"].get("partition_key"),
115
+ "triggers": [
116
+ {
117
+ "id": uow["event"]["id"],
118
+ "type": uow["event"]["type"],
119
+ "timestamp": uow["event"].get("timestamp"),
120
+ }
121
+ ],
122
+ }
123
+ event = self.rule["to_event"](uow, self, template)
124
+ return adorn_standard_tags("scheduled_event")({
125
+ **uow,
126
+ "scheduled_event": event,
127
+ })["scheduled_event"]
128
+
129
+ def _resolve_schedule_at(self, uow: Uow) -> datetime:
130
+ has_schedule_at = "schedule_at" in self.rule
131
+ has_delay_minutes = "delay_minutes" in self.rule
132
+ if has_schedule_at == has_delay_minutes:
133
+ raise ValueError(
134
+ "Schedule requires exactly one of schedule_at or delay_minutes."
135
+ )
136
+
137
+ if has_schedule_at:
138
+ return self.rule["schedule_at"](uow)
139
+
140
+ delay_minutes = self._value("delay_minutes", uow)
141
+ if isinstance(delay_minutes, bool) or not isinstance(delay_minutes, int):
142
+ raise ValueError("delay_minutes must resolve to a non-negative integer.")
143
+ if delay_minutes < 0:
144
+ raise ValueError("delay_minutes must resolve to a non-negative integer.")
145
+
146
+ timestamp = uow["event"].get("timestamp")
147
+ if timestamp is None:
148
+ raise ValueError("delay_minutes requires event.timestamp.")
149
+ return datetime.fromtimestamp(
150
+ timestamp / 1000,
151
+ tz=timezone.utc,
152
+ ) + timedelta(minutes=delay_minutes)
153
+
154
+ def _value(self, key: str, uow: Uow, default=None):
155
+ value = self.rule.get(key, default)
156
+ return value(uow) if callable(value) else value
157
+
158
+ @staticmethod
159
+ def _schedule_expression(value: datetime) -> str:
160
+ return "at({})".format(
161
+ value.astimezone(timezone.utc).strftime("%Y-%m-%dT%H:%M:%S")
162
+ )
@@ -0,0 +1,36 @@
1
+ from reactivex import Observable
2
+
3
+ from modmex_lambda.connectors.ieventbridge_scheduler import (
4
+ IEventBridgeSchedulerConnector,
5
+ )
6
+ from modmex_lambda.stream.operators.ioperator import IOperator
7
+ from modmex_lambda.stream.utils.faults import faulty
8
+ from modmex_lambda.stream.utils.operators import try_map
9
+
10
+
11
+ class SchedulerOps(IOperator):
12
+ """Reactive operator that submits prepared EventBridge schedules."""
13
+
14
+ def __init__(
15
+ self,
16
+ connector: IEventBridgeSchedulerConnector,
17
+ *,
18
+ request_field="schedule_request",
19
+ response_field="schedule_response",
20
+ ) -> None:
21
+ self.connector = connector
22
+ self.request_field = request_field
23
+ self.response_field = response_field
24
+
25
+ def __call__(self, source: Observable) -> Observable:
26
+ return source.pipe(try_map(faulty(self.invoke)))
27
+
28
+ def invoke(self, uow):
29
+ if not uow.get(self.request_field):
30
+ return uow
31
+ return {
32
+ **uow,
33
+ self.response_field: self.connector.create_schedule(
34
+ uow[self.request_field]
35
+ ),
36
+ }
@@ -2,13 +2,13 @@ import copy
2
2
  import multiprocessing
3
3
  import os
4
4
  import threading
5
+ from contextvars import Token
5
6
  from typing import Any, Callable, Iterable, TypedDict
6
7
 
7
8
  from reactivex import Observable, from_list, operators as ops
8
- from reactivex.scheduler import ThreadPoolScheduler
9
- from contextvars import Token
10
9
 
11
10
  from modmex_lambda.stream.irules_registry import IRulesRegistry
11
+ from modmex_lambda.stream.schedulers import ContextThreadPoolScheduler
12
12
  from modmex_lambda.stream.utils.eventbridge import publish_to_event_bridge
13
13
  from modmex_lambda.stream.utils.faults import flush_faults
14
14
  from modmex_lambda.logging import Logger
@@ -47,7 +47,7 @@ def run(
47
47
  **(opt or {}),
48
48
  }
49
49
  optimal_thread_count = multiprocessing.cpu_count()
50
- pool_scheduler = ThreadPoolScheduler(optimal_thread_count)
50
+ pool_scheduler = ContextThreadPoolScheduler(optimal_thread_count)
51
51
  pipeline_logger = opt.get('logger') or Logger()
52
52
 
53
53
 
@@ -0,0 +1,15 @@
1
+ from contextvars import copy_context
2
+
3
+ from reactivex.scheduler import ThreadPoolScheduler
4
+
5
+
6
+ class ContextThreadPoolScheduler(ThreadPoolScheduler):
7
+ """Thread-pool scheduler that preserves the scheduling context."""
8
+
9
+ class ThreadPoolThread(ThreadPoolScheduler.ThreadPoolThread):
10
+ def __init__(self, executor, target):
11
+ super().__init__(executor, target)
12
+ self.context = copy_context()
13
+
14
+ def start(self) -> None:
15
+ self.future = self.executor.submit(self.context.run, self.target)
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "modmex-lambda"
7
- version = "0.5.11"
7
+ version = "0.6.0"
8
8
  description = "Ultra-lightweight AWS Lambda utilities for API Gateway routing and event handling."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10,<4.0"
@@ -2,6 +2,9 @@ from expects import equal, expect
2
2
  from modmex_lambda.connectors.cloudwatch import Connector as CloudwatchConnector
3
3
  from modmex_lambda.connectors.dynamodb import Connector as DynamoConnector
4
4
  from modmex_lambda.connectors.eventbridge import Connector as EventbridgeConnector
5
+ from modmex_lambda.connectors.eventbridge_scheduler import (
6
+ Connector as EventbridgeSchedulerConnector,
7
+ )
5
8
  from modmex_lambda.connectors.lambda_ import Connector as LambdaConnector
6
9
  from modmex_lambda.connectors.s3 import Connector as S3Connector
7
10
  from modmex_lambda.connectors.sns import Connector as SnsConnector
@@ -46,6 +49,9 @@ def test_lazy_boto_clients(monkeypatch):
46
49
 
47
50
  expect(CloudwatchConnector().client).to(equal({'client': 'cloudwatch', 'kwargs': {}}))
48
51
  expect(EventbridgeConnector().client).to(equal({'client': 'events', 'kwargs': {}}))
52
+ expect(EventbridgeSchedulerConnector().client).to(equal({
53
+ 'client': 'scheduler', 'kwargs': {}
54
+ }))
49
55
  expect(LambdaConnector().client).to(equal({'client': 'lambda', 'kwargs': {}}))
50
56
  expect(S3Connector('bucket').client).to(equal({'client': 's3', 'kwargs': {}}))
51
57
  expect(SqsConnector('queue').client).to(equal({'client': 'sqs', 'kwargs': {}}))
@@ -60,6 +66,7 @@ def test_lazy_boto_clients(monkeypatch):
60
66
  expect(boto.client_calls).to(equal([
61
67
  (('cloudwatch',), {}),
62
68
  (('events',), {}),
69
+ (('scheduler',), {}),
63
70
  (('lambda',), {}),
64
71
  (('s3',), {}),
65
72
  (('sqs',), {}),
@@ -1,6 +1,9 @@
1
1
  from expects import equal, expect
2
2
  from modmex_lambda.connectors.cloudwatch import Connector as CloudwatchConnector
3
3
  from modmex_lambda.connectors.eventbridge import Connector as EventbridgeConnector
4
+ from modmex_lambda.connectors.eventbridge_scheduler import (
5
+ Connector as EventbridgeSchedulerConnector,
6
+ )
4
7
  from modmex_lambda.connectors.lambda_ import Connector as LambdaConnector
5
8
 
6
9
 
@@ -20,6 +23,16 @@ class Client:
20
23
  'events': True,
21
24
  }
22
25
 
26
+ def create_schedule(self, **kwargs):
27
+ self.calls.append(('create_schedule', kwargs))
28
+ return {
29
+ 'schedule': True,
30
+ }
31
+
32
+ def delete_schedule(self, **kwargs):
33
+ self.calls.append(('delete_schedule', kwargs))
34
+ return {}
35
+
23
36
  def invoke(self, **kwargs):
24
37
  self.calls.append(('invoke', kwargs))
25
38
  return {
@@ -59,6 +72,21 @@ def test_eventbridge_put_events():
59
72
  expect(result).to(equal({'events': True}))
60
73
 
61
74
 
75
+ def test_eventbridge_scheduler_creates_and_deletes_schedule():
76
+ client = Client()
77
+ connector = EventbridgeSchedulerConnector(client)
78
+
79
+ created = connector.create_schedule({'Name': 'once'})
80
+ deleted = connector.delete_schedule({'Name': 'once'})
81
+
82
+ expect(client.calls).to(equal([
83
+ ('create_schedule', {'Name': 'once'}),
84
+ ('delete_schedule', {'Name': 'once'}),
85
+ ]))
86
+ expect(created).to(equal({'schedule': True}))
87
+ expect(deleted).to(equal({}))
88
+
89
+
62
90
  def test_lambda_invoke():
63
91
  client = Client()
64
92
 
@@ -3,6 +3,9 @@ from expects import equal, expect
3
3
  from modmex_lambda.connectors.icloudwatch import ICloudWatchConnector
4
4
  from modmex_lambda.connectors.idynamodb import IDynamodbConnector
5
5
  from modmex_lambda.connectors.ieventbridge import IEventBridgeConnector
6
+ from modmex_lambda.connectors.ieventbridge_scheduler import (
7
+ IEventBridgeSchedulerConnector,
8
+ )
6
9
  from modmex_lambda.connectors.ilambda import ILambdaConnector
7
10
  from modmex_lambda.connectors.is3 import IS3Connector
8
11
  from modmex_lambda.connectors.isns import ISNSConnector
@@ -15,6 +18,7 @@ from modmex_lambda.stream.operators.publisher import Publisher
15
18
  from modmex_lambda.stream.operators.s3 import S3Ops
16
19
  from modmex_lambda.stream.operators.sns import SNSOps
17
20
  from modmex_lambda.stream.operators.sqs import SQSOps
21
+ from modmex_lambda.stream.operators.scheduler import SchedulerOps
18
22
 
19
23
 
20
24
  class Resolver:
@@ -23,6 +27,7 @@ class Resolver:
23
27
  ICloudWatchConnector: object(),
24
28
  IDynamodbConnector: object(),
25
29
  IEventBridgeConnector: object(),
30
+ IEventBridgeSchedulerConnector: object(),
26
31
  ILambdaConnector: object(),
27
32
  IS3Connector: object(),
28
33
  ISNSConnector: object(),
@@ -52,6 +57,7 @@ def test_base_flavor_lazily_creates_ops_and_publisher():
52
57
  expect(isinstance(flavor.s3_ops, S3Ops)).to(equal(True))
53
58
  expect(isinstance(flavor.sns_ops, SNSOps)).to(equal(True))
54
59
  expect(isinstance(flavor.sqs_ops, SQSOps)).to(equal(True))
60
+ expect(isinstance(flavor.scheduler_ops, SchedulerOps)).to(equal(True))
55
61
  expect(isinstance(flavor.publisher, Publisher)).to(equal(True))
56
62
  expect(flavor.publisher).to(equal(flavor.publisher))
57
63