fix(shared): 🐛 fix: 🐛 resolve duplicate event processing in system-events processor
This commit is contained in:
parent
4ca0e696cf
commit
2ff9136e40
4 changed files with 15 additions and 20 deletions
|
|
@ -102,8 +102,8 @@ interface PipelineState {
|
|||
*/
|
||||
@Processor(DOMAIN_EVENTS_QUEUE)
|
||||
@Injectable()
|
||||
export class SeoEventsProcessor extends WorkerHost {
|
||||
private readonly logger = new Logger(SeoEventsProcessor.name);
|
||||
export class SeoEventsProcessor extends BaseDomainEventsProcessor {
|
||||
protected readonly logger = new Logger(SeoEventsProcessor.name);
|
||||
|
||||
/**
|
||||
* In-memory state storage for pipeline orchestration.
|
||||
|
|
@ -112,12 +112,6 @@ export class SeoEventsProcessor extends WorkerHost {
|
|||
*/
|
||||
private readonly pipelineStates = new Map<string, PipelineState>();
|
||||
|
||||
/**
|
||||
* Idempotency tracking to prevent duplicate event processing.
|
||||
* Uses event idempotencyKey to deduplicate.
|
||||
*/
|
||||
private readonly processedEvents = new Set<string>();
|
||||
|
||||
constructor(
|
||||
@InjectRepository(SEOContentEntity)
|
||||
private readonly contentRepository: Repository<SEOContentEntity>,
|
||||
|
|
|
|||
|
|
@ -80,6 +80,8 @@ document.getElementById('register-form')?.addEventListener('submit', async (e) =
|
|||
const username = document.getElementById('username').value;
|
||||
const password = document.getElementById('password').value;
|
||||
const confirmPassword = document.getElementById('confirmPassword').value;
|
||||
const roleElement = document.getElementById('role');
|
||||
const role = roleElement ? roleElement.value : null;
|
||||
|
||||
if (password !== confirmPassword) {
|
||||
alert('Passwords do not match');
|
||||
|
|
@ -87,10 +89,15 @@ document.getElementById('register-form')?.addEventListener('submit', async (e) =
|
|||
}
|
||||
|
||||
try {
|
||||
const body = { email, username, password };
|
||||
if (role) {
|
||||
body.role = role;
|
||||
}
|
||||
|
||||
const response = await fetch('/auth/register', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ email, username, password }),
|
||||
body: JSON.stringify(body),
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
|
|
|
|||
|
|
@ -14,6 +14,9 @@
|
|||
<div class="error-message">{{error}}</div>
|
||||
{{/if}}
|
||||
<form id="register-form">
|
||||
{{#if role}}
|
||||
<input type="hidden" id="role" name="role" value="{{role}}">
|
||||
{{/if}}
|
||||
<div class="form-group">
|
||||
<label for="email">Email</label>
|
||||
<input type="email" id="email" name="email" required>
|
||||
|
|
|
|||
|
|
@ -39,17 +39,8 @@ type SystemEvent =
|
|||
|
||||
@Processor('DOMAIN_EVENTS')
|
||||
@Injectable()
|
||||
export class SystemEventsProcessor extends WorkerHost {
|
||||
private readonly logger = new Logger(SystemEventsProcessor.name)
|
||||
|
||||
/**
|
||||
* In-memory set for idempotency tracking.
|
||||
* Prevents duplicate processing of events with the same idempotencyKey.
|
||||
*
|
||||
* Note: This is volatile (cleared on restart). For production with
|
||||
* multiple replicas, consider Redis-backed idempotency.
|
||||
*/
|
||||
private readonly processedEvents = new Set<string>()
|
||||
export class SystemEventsProcessor extends BaseDomainEventsProcessor {
|
||||
protected readonly logger = new Logger(SystemEventsProcessor.name)
|
||||
|
||||
constructor(
|
||||
private readonly metricsStorage: MetricsStorageService,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue