Skip to content

Commit 83a01a6

Browse files
committed
Remove support for STRONTIUM_EVENT_NAME in GCPS
1 parent 6c0dae0 commit 83a01a6

File tree

3 files changed

+15
-27
lines changed

3 files changed

+15
-27
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "strontium",
3-
"version": "2.4.16",
3+
"version": "2.5.0",
44
"description": "Strontium is a TypeScript toolkit for High Performance API servers built for Production not Projects.",
55
"main": "lib/src/index.js",
66
"types": "lib/src/index.d.ts",

src/queue/abstract/SerializedTask.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
export interface SerializedTask {
2-
eventName: string
32
message: any
43
}

src/queue/drivers/gcps/GCPSConsumer.ts

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ export class GCPSConsumer implements Process {
2020
keyId: string,
2121
privateKey: string,
2222
public subscriptionName: string,
23-
public taskHandlers: {
24-
[eventName: string]: ConstructorOf<QueueHandler<any>>
25-
},
23+
public taskHandler: ConstructorOf<QueueHandler<any>>,
2624
public prefetchCount: number = 15
2725
) {
2826
this.client = new GCPSClient(serviceAccountEmail, keyId, privateKey)
@@ -98,21 +96,9 @@ export class GCPSConsumer implements Process {
9896

9997
await Promise.all(
10098
messages.map(async (m) => {
101-
if (m.message.attributes === undefined) {
102-
if (this.logger) {
103-
this.logger.info(
104-
`[GCPS - TASK - START] Event discarded due to corrupted attributes.`
105-
)
106-
}
107-
108-
return this.ack(m.ackId)
109-
}
110-
11199
return this.executeTask(
112100
m.ackId,
113101
{
114-
eventName:
115-
m.message.attributes.STRONTIUM_EVENT_NAME,
116102
message: m.message.data,
117103
},
118104
container
@@ -136,21 +122,23 @@ export class GCPSConsumer implements Process {
136122
requestContainer.parent = applicationContainer
137123

138124
// Spawn a handler for the Task type
139-
let handlerType = this.taskHandlers[task.eventName]
125+
let handlerType = this.taskHandler
140126
if (this.logger) {
141127
this.logger.info(
142-
`[GCPS - TASK - START] Event of type ${
143-
task.eventName
144-
} received by Consumer.`
128+
`[GCPS - TASK - START] Event received by Consumer for topic.`,
129+
{
130+
subscription: this.subscriptionName
131+
}
145132
)
146133
}
147134

148135
if (handlerType === undefined) {
149136
if (this.logger) {
150137
this.logger.error(
151-
`[GCPS - TASK - NO_IMPLEMENTATION_FAIL] No implementation found for event ${
152-
task.eventName
153-
}`
138+
`[GCPS - TASK - NO_IMPLEMENTATION_FAIL] No implementation found for topic.`,
139+
{
140+
subscription: this.subscriptionName
141+
}
154142
)
155143
}
156144
await this.nack(ackId)
@@ -176,9 +164,10 @@ export class GCPSConsumer implements Process {
176164
await this.ack(ackId)
177165
if (this.logger) {
178166
this.logger.info(
179-
`[GCPS - TASK - SUCCESS] Event of type ${
180-
task.eventName
181-
} successfully completed by Consumer.`
167+
`[GCPS - TASK - SUCCESS] Event successfully completed by Consumer.`,
168+
{
169+
subscription: this.subscriptionName
170+
}
182171
)
183172
}
184173
} catch (e) {

0 commit comments

Comments
 (0)