modmex-lambda 0.5.12__tar.gz → 0.6.1__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 (253) hide show
  1. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/PKG-INFO +60 -1
  2. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/README.md +59 -0
  3. modmex_lambda-0.6.1/modmex_lambda/connectors/eventbridge_scheduler.py +24 -0
  4. modmex_lambda-0.6.1/modmex_lambda/connectors/ieventbridge_scheduler.py +21 -0
  5. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/connectors/module.py +10 -0
  6. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/stream/events/s3.py +29 -1
  7. modmex_lambda-0.6.1/modmex_lambda/stream/flavors/__init__.py +24 -0
  8. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/stream/flavors/base_flavor.py +15 -0
  9. modmex_lambda-0.6.1/modmex_lambda/stream/flavors/schedule.py +195 -0
  10. modmex_lambda-0.6.1/modmex_lambda/stream/operators/scheduler.py +36 -0
  11. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/pyproject.toml +1 -1
  12. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/connectors/test_lazy_clients.py +7 -0
  13. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/connectors/test_simple_connectors.py +28 -0
  14. modmex_lambda-0.6.1/tests/stream/events/test_s3.py +106 -0
  15. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/stream/flavors/test_base_flavor.py +6 -0
  16. modmex_lambda-0.6.1/tests/stream/flavors/test_schedule.py +249 -0
  17. modmex_lambda-0.6.1/tests/stream/operators/test_scheduler.py +39 -0
  18. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/stream/test_dependency_resolver.py +7 -0
  19. modmex_lambda-0.5.12/tests/stream/events/test_s3.py +0 -54
  20. modmex_lambda-0.5.12/tests/stream/utils/__init__.py +0 -0
  21. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/.github/workflows/ci.yml +0 -0
  22. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/.github/workflows/release.yml +0 -0
  23. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/.gitignore +0 -0
  24. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/LICENSE +0 -0
  25. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/__init__.py +0 -0
  26. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/connectors/__init__.py +0 -0
  27. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/connectors/cloudwatch.py +0 -0
  28. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/connectors/dynamodb.py +0 -0
  29. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/connectors/eventbridge.py +0 -0
  30. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/connectors/icloudwatch.py +0 -0
  31. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/connectors/idynamodb.py +0 -0
  32. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/connectors/ieventbridge.py +0 -0
  33. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/connectors/ilambda.py +0 -0
  34. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/connectors/is3.py +0 -0
  35. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/connectors/isns.py +0 -0
  36. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/connectors/isqs.py +0 -0
  37. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/connectors/lambda_.py +0 -0
  38. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/connectors/s3.py +0 -0
  39. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/connectors/sns.py +0 -0
  40. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/connectors/sqs.py +0 -0
  41. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/data_classes/__init__.py +0 -0
  42. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/data_classes/api_gateway_authorizer_event.py +0 -0
  43. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/data_classes/api_gateway_proxy_event.py +0 -0
  44. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/data_classes/api_gateway_websocket_event.py +0 -0
  45. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/data_classes/cognito_user_pool_event.py +0 -0
  46. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/data_classes/common.py +0 -0
  47. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/dependencies.py +0 -0
  48. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/event_handler/__init__.py +0 -0
  49. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/event_handler/api_gateway.py +0 -0
  50. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/event_handler/constants.py +0 -0
  51. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/event_handler/content_types.py +0 -0
  52. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/event_handler/cors.py +0 -0
  53. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/event_handler/dependencies/__init__.py +0 -0
  54. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/event_handler/dependencies/compat.py +0 -0
  55. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/event_handler/dependencies/dependant.py +0 -0
  56. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/event_handler/dependencies/dependency_middleware.py +0 -0
  57. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/event_handler/dependencies/depends.py +0 -0
  58. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/event_handler/dependencies/params.py +0 -0
  59. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/event_handler/dependencies/types.py +0 -0
  60. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/event_handler/exception_handler.py +0 -0
  61. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/event_handler/exceptions.py +0 -0
  62. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/event_handler/gateway_response.py +0 -0
  63. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/event_handler/middlewares.py +0 -0
  64. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/event_handler/params.py +0 -0
  65. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/event_handler/request.py +0 -0
  66. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/event_handler/response.py +0 -0
  67. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/event_handler/routing.py +0 -0
  68. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/event_handler/routing_fallbacks.py +0 -0
  69. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/event_handler/types.py +0 -0
  70. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/event_sources.py +0 -0
  71. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/exceptions.py +0 -0
  72. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/logging.py +0 -0
  73. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/params.py +0 -0
  74. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/parser.py +0 -0
  75. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/persistence/__init__.py +0 -0
  76. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/persistence/dynamodb/__init__.py +0 -0
  77. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/persistence/dynamodb/expressions.py +0 -0
  78. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/persistence/dynamodb/keys.py +0 -0
  79. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/persistence/dynamodb/materialized_views.py +0 -0
  80. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/persistence/dynamodb/stream_fields.py +0 -0
  81. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/py.typed +0 -0
  82. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/request.py +0 -0
  83. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/resolver.py +0 -0
  84. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/response.py +0 -0
  85. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/routing.py +0 -0
  86. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/shared/__init__.py +0 -0
  87. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/shared/cookies.py +0 -0
  88. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/shared/headers_serializer.py +0 -0
  89. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/shared/json_encoder.py +0 -0
  90. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/shared/types.py +0 -0
  91. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/stream/__init__.py +0 -0
  92. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/stream/events/__init__.py +0 -0
  93. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/stream/events/dynamodb.py +0 -0
  94. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/stream/events/kinesis.py +0 -0
  95. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/stream/events/sns.py +0 -0
  96. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/stream/events/sqs.py +0 -0
  97. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/stream/filters/__init__.py +0 -0
  98. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/stream/filters/content.py +0 -0
  99. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/stream/filters/event_type.py +0 -0
  100. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/stream/filters/latch.py +0 -0
  101. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/stream/filters/skip.py +0 -0
  102. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/stream/flavors/cdc.py +0 -0
  103. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/stream/flavors/collect.py +0 -0
  104. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/stream/flavors/correlate.py +0 -0
  105. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/stream/flavors/evaluate.py +0 -0
  106. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/stream/flavors/expired.py +0 -0
  107. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/stream/flavors/iflavor.py +0 -0
  108. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/stream/flavors/job.py +0 -0
  109. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/stream/flavors/materialize.py +0 -0
  110. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/stream/flavors/s3.py +0 -0
  111. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/stream/flavors/sns.py +0 -0
  112. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/stream/flavors/task.py +0 -0
  113. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/stream/flavors/update.py +0 -0
  114. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/stream/irules_registry.py +0 -0
  115. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/stream/operators/__init__.py +0 -0
  116. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/stream/operators/cloudwatch.py +0 -0
  117. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/stream/operators/dynamodb.py +0 -0
  118. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/stream/operators/ioperator.py +0 -0
  119. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/stream/operators/lambda_.py +0 -0
  120. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/stream/operators/publisher.py +0 -0
  121. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/stream/operators/s3.py +0 -0
  122. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/stream/operators/sns.py +0 -0
  123. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/stream/operators/sqs.py +0 -0
  124. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/stream/rules_registry.py +0 -0
  125. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/stream/runner.py +0 -0
  126. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/stream/schedulers.py +0 -0
  127. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/stream/sources/__init__.py +0 -0
  128. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/stream/sources/base.py +0 -0
  129. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/stream/sources/dynamodb.py +0 -0
  130. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/stream/sources/kinesis.py +0 -0
  131. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/stream/sources/s3.py +0 -0
  132. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/stream/sources/sns.py +0 -0
  133. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/stream/sources/sqs.py +0 -0
  134. {modmex_lambda-0.5.12/modmex_lambda/stream/flavors → modmex_lambda-0.6.1/modmex_lambda/stream/utils}/__init__.py +0 -0
  135. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/stream/utils/apigateway.py +0 -0
  136. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/stream/utils/aws.py +0 -0
  137. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/stream/utils/batch.py +0 -0
  138. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/stream/utils/cloudwatch.py +0 -0
  139. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/stream/utils/concurrency.py +0 -0
  140. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/stream/utils/contracts.py +0 -0
  141. {modmex_lambda-0.5.12/modmex_lambda/stream/utils → modmex_lambda-0.6.1/modmex_lambda/stream/utils/data_classes}/__init__.py +0 -0
  142. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/stream/utils/data_classes/dynamodb.py +0 -0
  143. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/stream/utils/decorators.py +0 -0
  144. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/stream/utils/dynamodb.py +0 -0
  145. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/stream/utils/eventbridge.py +0 -0
  146. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/stream/utils/faults.py +0 -0
  147. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/stream/utils/filters.py +0 -0
  148. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/stream/utils/json_encoder.py +0 -0
  149. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/stream/utils/lambda_.py +0 -0
  150. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/stream/utils/operators.py +0 -0
  151. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/stream/utils/pluralize.py +0 -0
  152. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/stream/utils/print.py +0 -0
  153. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/stream/utils/retry.py +0 -0
  154. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/stream/utils/s3.py +0 -0
  155. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/stream/utils/sns.py +0 -0
  156. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/stream/utils/split.py +0 -0
  157. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/stream/utils/sqs.py +0 -0
  158. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/stream/utils/tags.py +0 -0
  159. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/stream/utils/time.py +0 -0
  160. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/stream/utils/uow.py +0 -0
  161. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/tracing.py +0 -0
  162. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/modmex_lambda/validation.py +0 -0
  163. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/poetry.lock +0 -0
  164. {modmex_lambda-0.5.12/modmex_lambda/stream/utils/data_classes → modmex_lambda-0.6.1/tests}/__init__.py +0 -0
  165. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/conftest.py +0 -0
  166. {modmex_lambda-0.5.12/tests → modmex_lambda-0.6.1/tests/connectors}/__init__.py +0 -0
  167. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/connectors/conftest.py +0 -0
  168. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/connectors/test_cloudwatch.py +0 -0
  169. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/connectors/test_dynamodb.py +0 -0
  170. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/connectors/test_s3.py +0 -0
  171. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/connectors/test_sns.py +0 -0
  172. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/connectors/test_sqs.py +0 -0
  173. {modmex_lambda-0.5.12/tests/connectors → modmex_lambda-0.6.1/tests/data_classes}/__init__.py +0 -0
  174. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/data_classes/test_api_gateway_proxy_event.py +0 -0
  175. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/data_classes/test_cognito_user_pool_event.py +0 -0
  176. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/data_classes/test_common.py +0 -0
  177. {modmex_lambda-0.5.12/tests/data_classes → modmex_lambda-0.6.1/tests/event_handler}/__init__.py +0 -0
  178. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/event_handler/test_api_gateway.py +0 -0
  179. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/event_handler/test_cors.py +0 -0
  180. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/event_handler/test_dependencies.py +0 -0
  181. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/event_handler/test_exception_handler.py +0 -0
  182. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/event_handler/test_gateway_response.py +0 -0
  183. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/event_handler/test_request.py +0 -0
  184. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/event_handler/test_response.py +0 -0
  185. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/event_handler/test_routing.py +0 -0
  186. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/persistence/__init__.py +0 -0
  187. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/persistence/test_dynamodb_expressions.py +0 -0
  188. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/persistence/test_dynamodb_keys.py +0 -0
  189. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/persistence/test_dynamodb_materialized_views.py +0 -0
  190. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/persistence/test_dynamodb_stream_fields.py +0 -0
  191. {modmex_lambda-0.5.12/tests/event_handler → modmex_lambda-0.6.1/tests/shared}/__init__.py +0 -0
  192. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/shared/test_cookies_headers.py +0 -0
  193. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/shared/test_json_encoder.py +0 -0
  194. {modmex_lambda-0.5.12/tests/shared → modmex_lambda-0.6.1/tests/stream}/__init__.py +0 -0
  195. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/stream/conftest.py +0 -0
  196. {modmex_lambda-0.5.12/tests/stream → modmex_lambda-0.6.1/tests/stream/events}/__init__.py +0 -0
  197. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/stream/events/test_dynamodb.py +0 -0
  198. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/stream/events/test_kinesis.py +0 -0
  199. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/stream/events/test_sns.py +0 -0
  200. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/stream/events/test_sqs.py +0 -0
  201. {modmex_lambda-0.5.12/tests/stream/events → modmex_lambda-0.6.1/tests/stream/filters}/__init__.py +0 -0
  202. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/stream/filters/test_content.py +0 -0
  203. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/stream/filters/test_event_type.py +0 -0
  204. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/stream/filters/test_latch.py +0 -0
  205. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/stream/filters/test_skip.py +0 -0
  206. {modmex_lambda-0.5.12/tests/stream/filters → modmex_lambda-0.6.1/tests/stream/flavors}/__init__.py +0 -0
  207. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/stream/flavors/source_events.py +0 -0
  208. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/stream/flavors/test_cdc.py +0 -0
  209. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/stream/flavors/test_collect.py +0 -0
  210. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/stream/flavors/test_correlate.py +0 -0
  211. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/stream/flavors/test_evaluate.py +0 -0
  212. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/stream/flavors/test_expired.py +0 -0
  213. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/stream/flavors/test_job.py +0 -0
  214. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/stream/flavors/test_materialize.py +0 -0
  215. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/stream/flavors/test_s3.py +0 -0
  216. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/stream/flavors/test_sns.py +0 -0
  217. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/stream/flavors/test_task.py +0 -0
  218. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/stream/flavors/test_update.py +0 -0
  219. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/stream/test_faults.py +0 -0
  220. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/stream/test_rules_registry.py +0 -0
  221. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/stream/test_runner.py +0 -0
  222. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/stream/test_runner_pipeline.py +0 -0
  223. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/stream/test_sources.py +0 -0
  224. {modmex_lambda-0.5.12/tests/stream/flavors → modmex_lambda-0.6.1/tests/stream/utils}/__init__.py +0 -0
  225. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/stream/utils/faults.py +0 -0
  226. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/stream/utils/test_apigateway.py +0 -0
  227. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/stream/utils/test_aws.py +0 -0
  228. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/stream/utils/test_batch.py +0 -0
  229. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/stream/utils/test_cloudwatch.py +0 -0
  230. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/stream/utils/test_concurrency.py +0 -0
  231. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/stream/utils/test_decorators.py +0 -0
  232. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/stream/utils/test_dynamodb.py +0 -0
  233. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/stream/utils/test_eventbridge.py +0 -0
  234. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/stream/utils/test_filters.py +0 -0
  235. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/stream/utils/test_json_encoder.py +0 -0
  236. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/stream/utils/test_lambda.py +0 -0
  237. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/stream/utils/test_operators.py +0 -0
  238. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/stream/utils/test_pluralize.py +0 -0
  239. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/stream/utils/test_print.py +0 -0
  240. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/stream/utils/test_retry.py +0 -0
  241. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/stream/utils/test_s3.py +0 -0
  242. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/stream/utils/test_sns.py +0 -0
  243. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/stream/utils/test_split.py +0 -0
  244. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/stream/utils/test_sqs.py +0 -0
  245. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/stream/utils/test_tags.py +0 -0
  246. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/stream/utils/test_time.py +0 -0
  247. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/stream/utils/test_uow.py +0 -0
  248. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/test_lazy_imports.py +0 -0
  249. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/test_logging.py +0 -0
  250. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/test_parser_event_sources.py +0 -0
  251. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/test_reexports.py +0 -0
  252. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/tests/test_tracing.py +0 -0
  253. {modmex_lambda-0.5.12 → modmex_lambda-0.6.1}/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.12
3
+ Version: 0.6.1
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,63 @@ 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
+
1191
+ If the calculated deadline has already passed when the source event is
1192
+ processed, `Schedule` does not create an invalid `at(...)` schedule. It
1193
+ publishes the deferred domain event immediately on the configured bus instead.
1194
+
1138
1195
  ### Event Hub
1139
1196
 
1140
1197
  EventBridge is a natural hub for domain events. Flavors like
@@ -1154,6 +1211,8 @@ language and should be routed by event type, source, account, or bus.
1154
1211
  per-item results.
1155
1212
  - `Expired`: consumes DynamoDB TTL `REMOVE` records and publishes expiration
1156
1213
  events.
1214
+ - `Schedule`: schedules one standard domain event for a future time through
1215
+ EventBridge Scheduler.
1157
1216
  - `S3`: writes objects to S3.
1158
1217
  - `Sns`: publishes messages to SNS.
1159
1218
  - `Update`: queries, gets, and updates DynamoDB records.
@@ -1112,6 +1112,63 @@ 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
+
1168
+ If the calculated deadline has already passed when the source event is
1169
+ processed, `Schedule` does not create an invalid `at(...)` schedule. It
1170
+ publishes the deferred domain event immediately on the configured bus instead.
1171
+
1115
1172
  ### Event Hub
1116
1173
 
1117
1174
  EventBridge is a natural hub for domain events. Flavors like
@@ -1131,6 +1188,8 @@ language and should be routed by event type, source, account, or bus.
1131
1188
  per-item results.
1132
1189
  - `Expired`: consumes DynamoDB TTL `REMOVE` records and publishes expiration
1133
1190
  events.
1191
+ - `Schedule`: schedules one standard domain event for a future time through
1192
+ EventBridge Scheduler.
1134
1193
  - `S3`: writes objects to S3.
1135
1194
  - `Sns`: publishes messages to SNS.
1136
1195
  - `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:
@@ -1,4 +1,4 @@
1
- #pylint: disable=C0301
1
+ import json
2
2
  import pydash
3
3
  from pydash import get
4
4
 
@@ -15,6 +15,34 @@ def from_s3(event):
15
15
  }
16
16
  )
17
17
 
18
+ def from_sqs_sns_s3(event):
19
+ """Normalize an S3 notification delivered through SNS and SQS.
20
+
21
+ An SNS message can contain more than one S3 record, so this function
22
+ returns one UOW per S3 record. The event contract is the same as
23
+ :func:`from_s3`; the transport envelopes are retained in ``record``.
24
+ """
25
+ return pydash._(event['Records']).map(
26
+ lambda sqs_record: _from_sqs_record(sqs_record)
27
+ ).flatten().value()
28
+
29
+
30
+ def _from_sqs_record(sqs_record):
31
+ sns_record = json.loads(sqs_record['body'])
32
+ s3_event = json.loads(sns_record['Message'])
33
+
34
+ return pydash.map_(
35
+ from_s3(s3_event),
36
+ lambda uow: {
37
+ **uow,
38
+ 'record': {
39
+ 'sqs': sqs_record,
40
+ 'sns': sns_record,
41
+ 's3': uow['record'],
42
+ },
43
+ },
44
+ )
45
+
18
46
  def _calculate_event_type_prefix(record):
19
47
  if record['eventName'] in ['ObjectCreated:Post','ObjectCreated:Put']:
20
48
  return 'object-created'
@@ -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,195 @@
1
+ import json
2
+ import os
3
+ from datetime import datetime, timedelta, timezone
4
+ from typing import Any, Callable, Optional
5
+
6
+ from pydash import get
7
+ from reactivex import Observable, operators as ops
8
+
9
+ from modmex_lambda.connectors.ieventbridge import IEventBridgeConnector
10
+ from modmex_lambda.dependencies import DependencyResolver
11
+ from modmex_lambda.stream.flavors.base_flavor import BaseFlavor
12
+ from modmex_lambda.stream.operators.publisher import PublisherOptions
13
+ from modmex_lambda.stream.utils.contracts import BaseRule, Event, Uow
14
+ from modmex_lambda.stream.utils.faults import faulty
15
+ from modmex_lambda.stream.utils.filters import on_content, on_event_type
16
+ from modmex_lambda.stream.utils.operators import try_filter, try_map
17
+ from modmex_lambda.stream.utils.print import print_end, print_start
18
+ from modmex_lambda.stream.utils.tags import adorn_standard_tags
19
+
20
+
21
+ class ScheduleRule(BaseRule, total=False):
22
+ """Declares a one-time future delivery of a standard domain event."""
23
+
24
+ schedule_at: Callable[[Uow], datetime]
25
+ delay_minutes: int | Callable[[Uow], int]
26
+ schedule_name: str | Callable[[Uow], str]
27
+ to_event: Callable[[Uow, "Schedule", Event], Event]
28
+ bus_arn: str | Callable[[Uow], str]
29
+ role_arn: str | Callable[[Uow], str]
30
+ group_name: str | Callable[[Uow], str]
31
+ source: str | Callable[[Uow], str]
32
+ client_token: str | Callable[[Uow], str]
33
+
34
+
35
+ class Schedule(BaseFlavor):
36
+ """Schedules a standard domain event for one future point in time."""
37
+
38
+ def __init__(
39
+ self,
40
+ rule: ScheduleRule,
41
+ *,
42
+ logger: Optional[Any] = None,
43
+ connector: Optional[IEventBridgeConnector] = None,
44
+ dependency_resolver: Optional[DependencyResolver] = None,
45
+ publisher_options: Optional[PublisherOptions] = None,
46
+ ) -> None:
47
+ super().__init__(
48
+ logger=logger,
49
+ connector=connector,
50
+ dependency_resolver=dependency_resolver,
51
+ publisher_options={
52
+ **(publisher_options or {}),
53
+ "event_field": "emit",
54
+ **(
55
+ {"source": rule["source"]}
56
+ if isinstance(rule.get("source"), str)
57
+ else {}
58
+ ),
59
+ },
60
+ )
61
+ self.rule = rule
62
+
63
+ @property
64
+ def id(self):
65
+ return self.rule["id"]
66
+
67
+ def __call__(self, source: Observable):
68
+ return source.pipe(
69
+ try_filter(self._for_collected_events),
70
+ try_map(self._normalize),
71
+ try_filter(on_event_type(self.rule)),
72
+ ops.do_action(print_start(self.logger)),
73
+ try_filter(on_content(self.rule)),
74
+ try_map(faulty(self._to_schedule_request)),
75
+ self.scheduler_ops,
76
+ self.publisher,
77
+ ops.do_action(print_end(self.logger)),
78
+ )
79
+
80
+ @staticmethod
81
+ def _for_collected_events(uow: Uow) -> bool:
82
+ return (
83
+ get(uow, "record.eventName") == "INSERT"
84
+ and get(uow, "record.dynamodb.Keys.sk.S") == "EVENT"
85
+ )
86
+
87
+ @staticmethod
88
+ def _normalize(uow: Uow) -> Uow:
89
+ return {
90
+ **uow,
91
+ "event": get(uow, "event.raw.new.event"),
92
+ }
93
+
94
+ def _to_schedule_request(self, uow: Uow) -> Uow:
95
+ schedule_at = self._resolve_schedule_at(uow)
96
+ if schedule_at.tzinfo is None:
97
+ raise ValueError("schedule_at must return a timezone-aware datetime.")
98
+
99
+ scheduled_event = self._to_event(uow, schedule_at)
100
+ bus_arn = self._value(
101
+ "bus_arn", uow, os.getenv("BUS_ARN")
102
+ )
103
+ role_arn = self._value("role_arn", uow, os.getenv("SCHEDULER_ROLE_ARN"))
104
+ if not bus_arn:
105
+ raise ValueError("bus_arn or BUS_ARN is required.")
106
+ if not role_arn:
107
+ raise ValueError("role_arn or SCHEDULER_ROLE_ARN is required.")
108
+ if schedule_at <= datetime.now(timezone.utc):
109
+ return {
110
+ **uow,
111
+ "scheduled_event": scheduled_event,
112
+ "emit": scheduled_event,
113
+ }
114
+ return {
115
+ **uow,
116
+ "scheduled_event": scheduled_event,
117
+ "emit": None,
118
+ "schedule_request": {
119
+ "Name": self._value("schedule_name", uow),
120
+ "GroupName": self._value("group_name", uow, "default"),
121
+ "ScheduleExpression": self._schedule_expression(schedule_at),
122
+ "FlexibleTimeWindow": {"Mode": "OFF"},
123
+ "ActionAfterCompletion": "DELETE",
124
+ "ClientToken": self._value("client_token", uow, scheduled_event["id"]),
125
+ "Target": {
126
+ "Arn": self._value(
127
+ "bus_arn", uow, bus_arn
128
+ ),
129
+ "RoleArn": self._value(
130
+ "role_arn", uow, role_arn
131
+ ),
132
+ "EventBridgeParameters": {
133
+ "Source": self._value(
134
+ "source", uow, os.getenv("BUS_SRC", "custom")
135
+ ),
136
+ "DetailType": scheduled_event["type"],
137
+ },
138
+ "Input": json.dumps(scheduled_event),
139
+ },
140
+ },
141
+ }
142
+
143
+ def _to_event(self, uow: Uow, schedule_at: datetime) -> Event:
144
+ template: Event = {
145
+ "id": self._value("client_token", uow, self._value("schedule_name", uow)),
146
+ "timestamp": int(schedule_at.timestamp() * 1000),
147
+ "partition_key": uow["event"].get("partition_key"),
148
+ "triggers": [
149
+ {
150
+ "id": uow["event"]["id"],
151
+ "type": uow["event"]["type"],
152
+ "timestamp": uow["event"].get("timestamp"),
153
+ }
154
+ ],
155
+ }
156
+ event = self.rule["to_event"](uow, self, template)
157
+ return adorn_standard_tags("scheduled_event")({
158
+ **uow,
159
+ "scheduled_event": event,
160
+ })["scheduled_event"]
161
+
162
+ def _resolve_schedule_at(self, uow: Uow) -> datetime:
163
+ has_schedule_at = "schedule_at" in self.rule
164
+ has_delay_minutes = "delay_minutes" in self.rule
165
+ if has_schedule_at == has_delay_minutes:
166
+ raise ValueError(
167
+ "Schedule requires exactly one of schedule_at or delay_minutes."
168
+ )
169
+
170
+ if has_schedule_at:
171
+ return self.rule["schedule_at"](uow)
172
+
173
+ delay_minutes = self._value("delay_minutes", uow)
174
+ if isinstance(delay_minutes, bool) or not isinstance(delay_minutes, int):
175
+ raise ValueError("delay_minutes must resolve to a non-negative integer.")
176
+ if delay_minutes < 0:
177
+ raise ValueError("delay_minutes must resolve to a non-negative integer.")
178
+
179
+ timestamp = uow["event"].get("timestamp")
180
+ if timestamp is None:
181
+ raise ValueError("delay_minutes requires event.timestamp.")
182
+ return datetime.fromtimestamp(
183
+ timestamp / 1000,
184
+ tz=timezone.utc,
185
+ ) + timedelta(minutes=delay_minutes)
186
+
187
+ def _value(self, key: str, uow: Uow, default=None):
188
+ value = self.rule.get(key, default)
189
+ return value(uow) if callable(value) else value
190
+
191
+ @staticmethod
192
+ def _schedule_expression(value: datetime) -> str:
193
+ return "at({})".format(
194
+ value.astimezone(timezone.utc).strftime("%Y-%m-%dT%H:%M:%S")
195
+ )
@@ -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
+ }
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "modmex-lambda"
7
- version = "0.5.12"
7
+ version = "0.6.1"
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