Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.forge.engine.event;

// Sealed interface ka matlab hai iske alawa aur koi class isko implement nahi kar sakti.
// Yeh Java 21 ka strict pattern matching feature hai.

public sealed interface EngineEvent permits BidPlacedEvent, AuctionEndedEvent {
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
package com.forge.engine.event;

/**
* Ye ek Functional Interface है.
* Jo bhi class engine ke events (jaise STOMP WebSocket bridge) sunna chahti hai,
* usko ye implement karna padega.
*/

@FunctionalInterface
public interface EngineEventListener {
void onEvent(EngineEvent event);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,12 @@ public void subscribe(EngineEventListener listener) {
log.info("New listener subscribed to EventBus");
}

/**
* PRODUCER: Called by BiddingEngine.
* Extremely fast. Just drops the event in the queue and returns.
*/

public void publish(EngineEvent event) {
eventQueue.offer(event);
}

/**
* CONSUMER: Infinite background loop running on a Virtual Thread.
*/

private void processEvents() {
log.info("EventBus Background Consumer Loop Started...");
while (!Thread.currentThread().isInterrupted()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class AuctionStateMachine {
private final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();

public AuctionStateMachine() {
// Default state jab auction create hota hai

this.currentState = AuctionState.DRAFT;
}

Expand Down Expand Up @@ -44,7 +44,6 @@ public boolean transitionTo(AuctionState newState) {
lock.writeLock().unlock();
}
}
// Yeh method AuctionStateMachine.java mein add kar
public void transitionToEnded() {
boolean success = transitionTo(AuctionState.ENDED);
if (!success) {
Expand Down
4 changes: 1 addition & 3 deletions forge-engine/src/main/java/com/forge/engine/model/Bid.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@

public record Bid(BidKey bidKey, String bidderId) {

// Backward Compatibility Constructor: Tera purana code yahi constructor call karega
// aur yeh automatically naya BidKey object generate kar lega!

public Bid(String bidderId, Money price) {
this(new BidKey(price, Instant.now()), bidderId);
}

// --- OLD GETTERS (Taaki tera bacha hua code break na ho) ---
public Money getPrice() {
return bidKey.amount();
}
Expand Down
Loading