Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(events): Add events framework for registering events #4115

Merged
merged 50 commits into from
Apr 10, 2024

Conversation

lsampras
Copy link
Member

@lsampras lsampras commented Mar 18, 2024

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

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

@lsampras lsampras self-assigned this Mar 18, 2024
SanchithHegde
SanchithHegde previously approved these changes Apr 4, 2024
crates/router/src/routes/app.rs Outdated Show resolved Hide resolved
crates/router/src/compatibility/wrap.rs Show resolved Hide resolved
crates/router/src/events.rs Outdated Show resolved Hide resolved
crates/router/src/events/event_logger.rs Outdated Show resolved Hide resolved
crates/router/src/services/api.rs Show resolved Hide resolved
crates/router/src/services/api.rs Show resolved Hide resolved
jarnura
jarnura previously approved these changes Apr 5, 2024
crates/router/src/events.rs Outdated Show resolved Hide resolved
Chethan-rao
Chethan-rao previously approved these changes Apr 5, 2024
Copy link
Contributor

@Chethan-rao Chethan-rao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Routing specific changes looks fine

@lsampras lsampras dismissed stale reviews from Chethan-rao and jarnura via de20710 April 10, 2024 11:37
@Gnanasundari24 Gnanasundari24 added this pull request to the merge queue Apr 10, 2024
Merged via the queue into main with commit 3963219 Apr 10, 2024
9 of 12 checks passed
@Gnanasundari24 Gnanasundari24 deleted the add_events_crate branch April 10, 2024 12:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat(events): create a framework for emitting events & capture audit/lifecycle events from application
8 participants