hyperswitch icon indicating copy to clipboard operation
hyperswitch copied to clipboard

feat(events): Add events framework for registering events

Open lsampras opened this issue 1 year ago • 0 comments

Type of Change

  • [ ] Bugfix
  • [ ] New feature
  • [ ] Enhancement
  • [ ] Refactoring
  • [ ] Dependency updates
  • [ ] Documentation
  • [ ] CI/CD

Description

  • Add a separate events crate for the events framework & implementation
  • Add a request State that will handle the request scoped state
  • This state can be mutable & is scoped to a particular request only
  • Generate this state as part of server_wrap that can be used to collect the request metadata & mutable variables to be used

Additional Changes

  • [ ] This PR modifies the API contract
  • [ ] This PR modifies the database schema
  • [ ] This PR modifies application configuration/environment variables

Motivation and Context

  • Adding events framework would need a request scoped context
  • In order to satisfy all such requirements of passing around a mutable state/variables we've added the RequestState that would be valid for the duration for a request
  • Since this State represents the request variables pertaining to the request such as flow / request id / trace id / connector etc can be easily recorded along with other domain variables

How did you test it?

  • Since this PR doesn't involve any new functionality I just ran the postman tests with stripe to verify this Screenshot 2024-03-19 at 5 19 22 PM

Checklist

  • [x] I formatted the code cargo +nightly fmt --all
  • [x] I addressed lints thrown by cargo clippy
  • [x] I reviewed the submitted code
  • [ ] I added unit tests for my changes where possible
  • [ ] I added a CHANGELOG entry if applicable

lsampras avatar Mar 18 '24 06:03 lsampras