Skip to content

Commit

Permalink
fix: print message id when handler not found (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
fengmk2 authored Aug 23, 2023
1 parent beca711 commit cfe091b
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/server/GRPCServerImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,6 @@ export default class GRPCServerImpl implements IAppCallbackServer {
const pubsubName = req.getPubsubName();
const topic = req.getTopic();
const metadata = convertMapToKVString(req.getMetadataMap());
const handler = this.findPubSubHandler(pubsubName, topic, metadata);
if (!handler) {
this.logger.warn('[layotto:server:grpc:onTopicEvent:warn] can\'t find the pubsub(%s) topic(%s) handler, let server retry',
pubsubName, topic);
res.setStatus(TopicEventResponse.TopicEventResponseStatus.RETRY);
return callback(null, res);
}
const request: TopicEventRequest = {
id: req.getId(),
source: req.getSource(),
Expand All @@ -114,12 +107,19 @@ export default class GRPCServerImpl implements IAppCallbackServer {
pubsubName,
metadata,
};
const handler = this.findPubSubHandler(pubsubName, topic, metadata);
if (!handler) {
this.logger.warn('[layotto:server:grpc:onTopicEvent:warn] can\'t find the pubsub(%s) topic(%s) id(%s) handler, let server retry',
pubsubName, topic, request.id);
res.setStatus(TopicEventResponse.TopicEventResponseStatus.RETRY);
return callback(null, res);
}
try {
await this.invokePubSubHandler(request, handler);
res.setStatus(TopicEventResponse.TopicEventResponseStatus.SUCCESS);
} catch (err: any) {
this.logger.error('[layotto:server:grpc:onTopicEvent:error] pubsub(%s) topic(%s) handler throw error %s, let server retry',
pubsubName, topic, err.message);
this.logger.error('[layotto:server:grpc:onTopicEvent:error] pubsub(%s) topic(%s) id(%s) handler throw error %s, let server retry',
pubsubName, topic, request.id, err.message);
this.logger.error(err);
res.setStatus(TopicEventResponse.TopicEventResponseStatus.RETRY);
}
Expand Down

0 comments on commit cfe091b

Please sign in to comment.