Phonepe Machine Coding Round

Anonymous User
650
Sep 26, 2022

Problem statement:
Consider a microservice env where several systems use 1 central system for all their alert use cases: Design and implement a system which can capture events generated by any system or user triggered (for simplicity), and raise an alert according to alert configuration.

Type of configurations:
SIMPLE_COUNT (which consists of count)
BUCKETED_WINDOW (which consists of count and windowSizeInSecs, Eg: 10 events in 1 hour bucket, you can assume that the bucket starts at 00:00 hour of the day)
MOVING_WINDOW (which consists of count and windowSizeInSecs)

Example client configuration:
alertConfigList:

[{	
	client: X
	eventType: PAYMENT_EXCEPTION, 
	alertConfig { 
		type: MOVING_WINDOW,
		count: 10
		windowSizeInSecs: 10
    },
    “dispatchStrategy”: {
		“type”: CONSOLE,
		“message” : “issue in payment”
	}
}
  • Alert will be dispatched if the config thresholds are met
  • You can design your own config.
  • You need to keep a placeholder for defining different dispatch mechanisms. (You may provide implementation for console dispatch)
  • Simulate the dispatch of alerts by generating events in a main class / test case

Expectations:
Separation of concerns
Abstractions
Application of OO design principles
Testability
Code readability
Language proficiency
Modular code

Comments (3)