Skip to content
This repository has been archived by the owner on Jan 9, 2024. It is now read-only.

chore(remove kinesis): stop sending events to unified event stream #815

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
2 changes: 0 additions & 2 deletions .aws/src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ export const config = {
envVars: {
databasePort: '3306',
sqsPublisherDataQueueName: 'pocket-publisher-data-queue',
sqsBatchDeleteQueueName: `${prefix}-Sqs-Batch-Delete-Consumer-Queue`,
sqsPermLibItemMainQueueName: `PermLib-${environment}-ItemMain`,
unifiedEventStreamName: 'unified_event',
databaseTz: 'US/Central',
eventBusName: `PocketEventBridge-${environment}-Shared-Event-Bus`,
},
Expand Down
28 changes: 0 additions & 28 deletions .aws/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,18 +248,10 @@ class ListAPI extends TerraformStack {
name: 'SQS_PUBLISHER_DATA_QUEUE_URL',
value: `https://sqs.${region.name}.amazonaws.com/${caller.accountId}/${config.envVars.sqsPublisherDataQueueName}`,
},
{
name: 'SQS_BATCH_DELETE_QUEUE_URL',
value: `https://sqs.${region.name}.amazonaws.com/${caller.accountId}/${config.envVars.sqsBatchDeleteQueueName}`,
},
{
name: 'SQS_PERMLIB_ITEMMAIN_QUEUE_URL',
value: `https://sqs.${region.name}.amazonaws.com/${caller.accountId}/${config.envVars.sqsPermLibItemMainQueueName}`,
},
{
name: 'KINESIS_UNIFIED_EVENT_STREAM',
value: config.envVars.unifiedEventStreamName,
},
{
name: 'DATABASE_TZ',
value: config.envVars.databaseTz,
Expand Down Expand Up @@ -397,26 +389,6 @@ class ListAPI extends TerraformStack {
],
effect: 'Allow',
},
{
//no permission for batchReceive as we want only one message polled at a time
actions: [
'sqs:ReceiveMessage',
'sqs:DeleteMessage',
'sqs:SendMessage',
'sqs:SendMessageBatch',
],
resources: [
`arn:aws:sqs:${region.name}:${caller.accountId}:${config.envVars.sqsBatchDeleteQueueName}`,
],
effect: 'Allow',
},
{
actions: ['kinesis:PutRecord', 'kinesis:PutRecords'],
resources: [
`arn:aws:kinesis:${region.name}:${caller.accountId}:stream/${config.envVars.unifiedEventStreamName}`,
],
effect: 'Allow',
},
{
actions: ['events:PutEvents'],
resources: [
Expand Down
28,631 changes: 8,315 additions & 20,316 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"@apollo/server-plugin-landing-page-graphql-playground": "4.0.0",
"@apollo/subgraph": "2.4.5",
"@aws-sdk/client-eventbridge": "3.92.0",
"@aws-sdk/client-kinesis": "3.53.0",
"@aws-sdk/client-sqs": "3.53.0",
"@opentelemetry/api": "1.3.0",
"@opentelemetry/exporter-trace-otlp-grpc": "0.34.0",
Expand Down
8 changes: 0 additions & 8 deletions src/aws/kinesis.ts

This file was deleted.

103 changes: 0 additions & 103 deletions src/businessEvents/eventBatchProcessor.spec.ts

This file was deleted.

112 changes: 0 additions & 112 deletions src/businessEvents/eventBatchProcessor.ts

This file was deleted.

21 changes: 0 additions & 21 deletions src/businessEvents/eventHandlers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { EventBatchProcessor } from './eventBatchProcessor';
import { unifiedEventKinesisHandler } from './unifiedEventKinesisHandler';
import { SqsListener } from './sqs/sqsListener';
import { ItemsEventEmitter } from './itemsEventEmitter';
import { SnowplowHandler } from './snowplowHandler';
Expand All @@ -11,25 +9,6 @@ import { EventBridgeHandler } from './eventBridgeHandler';

export type ItemEventHandlerFn = (emitter: ItemsEventEmitter) => void;

/**
* @param emitter
*/
export function unifiedEventHandler(emitter: ItemsEventEmitter): void {
// Create a list of event names (as strings) to register
// batch kinesis listener for unified event stream
const unifiedEventsToListen = Object.values(
config.aws.kinesis.unifiedEvents.events
) as string[];
// Start event batch handler for unified events to kinesis
new EventBatchProcessor( // eslint-disable-line
emitter,
unifiedEventsToListen,
unifiedEventKinesisHandler,
config.aws.kinesis.interval,
config.aws.kinesis.maxBatch
);
}

/**
* @param emitter
*/
Expand Down
2 changes: 0 additions & 2 deletions src/businessEvents/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
export * from './types';
export * from './eventBatchProcessor';
export * from './sqs/sqsListener';
export * from './unifiedEventKinesisHandler';
export * from './itemsEventEmitter';
export * from './snowplowHandler';
export * from './eventHandlers';
Expand Down
34 changes: 0 additions & 34 deletions src/businessEvents/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,45 +68,11 @@ export enum SQSEvents {
DELETE_ITEM = 6,
}

export type UnifiedEventType =
| 'user-list-item-created'
| 'user-item-archived'
| 'user-item-deleted'
| 'item-resolved'
| 'user-item-tags-added'
| 'user-item-tags-removed'
| 'user-item-tags-replaced'
| 'user-item-favorited'
| 'user-item-unfavorited'
| 'user-item-unarchived';

export type EventTypeString = keyof typeof EventType;
export type RequiredEvents = Exclude<
EventTypeString,
'DELETE_TAG' | 'RENAME_TAG'
>;
export const UnifiedEventMap: Record<RequiredEvents, UnifiedEventType> = {
ADD_ITEM: 'user-list-item-created',
DELETE_ITEM: 'user-item-deleted',
ARCHIVE_ITEM: 'user-item-archived',
UNARCHIVE_ITEM: 'user-item-unarchived',
FAVORITE_ITEM: 'user-item-favorited',
UNFAVORITE_ITEM: 'user-item-unfavorited',
ADD_TAGS: 'user-item-tags-added',
REPLACE_TAGS: 'user-item-tags-replaced',
REMOVE_TAGS: 'user-item-tags-removed',
CLEAR_TAGS: 'user-item-tags-removed',
};

// Generic key-value object for json event data
type GenericJsonData = {
[key: string]: any;
};

export type UnifiedEventPayload = BasicEventData & {
type: UnifiedEventType;
data: GenericJsonData;
};

export type SnowplowEventType =
| 'save'
Expand Down
Loading