Service Bus 主题触发器 Azure 函数中的事件组件命名约定

huangapple go评论60阅读模式
英文:

Naming convention of event components in Service Bus Topic Trigger Azure Function

问题

我正在使用Azure Functions。在我的应用程序中,我们使用Http触发器Azure函数来接收通知事件(例如UserCreatedEventUserDetailsUpdatedEvent等),然后这个Azure函数将该事件发布到Service Bus主题。我们为这个Service Bus主题创建了带有过滤器的订阅。对于每个订阅,我们都有相应的Service Bus主题触发器Azure函数。这些Service Bus主题触发器Azure函数用于发送通知。

那么,在这些Service Bus主题触发器Azure函数中,我们应该使用事件处理程序(UserCreatedEventHandler)还是事件处理器(UserCreatedEventProcessor)的命名约定呢?

有人能提供关于选择这些事件组件命名约定的指导吗?

英文:

I am working with Azure Functions, In my application we are using Http Trigger Azure Function to receive the notification events(i.e. UserCreatedEvent, UserDetailsUpdatedEvent etc.) and after this Azure Function publishing that event into Service Bus Topic. We have created subscriptions for this Service Bus topic with filter. For each subscription we have corresponding Service Bus Topic Trigger Azure Function. These Service Bus Topic Trigger Azure Functions sending the notifications.

So should we use EventHanlder(UserCreatedEventHandler) or EventProcessor(UserCreatedEventProcessor) naming convention in these Service Bus Topic Trigger Azure Function?

Can someone provide guidance on choosing a naming convention for these event components?

答案1

得分: 1

据我所知,特别是在为ServiceBus触发器或Azure函数触发器部分的代码命名时,并没有明确的规则(要遵循的步骤)。它完全取决于我们如何编写代码,以便我们理解代码并将其用于将来的代码使用。

实际上,

  • EventProcessor 用于处理从Service Bus主题传入/传出的事件(请求),然后通过电子邮件、消息或日志将有关此事件的信息传递给最终用户(需要向该用户发送信息的人)。
  • EventHandler 用于处理项目范围内的请求。

使用 UserCreatedEventProcessor 是个不错的选择,因为它清晰地说明了代码的功能,并且还取决于您的项目需求和团队的理解。

如果需要更多信息,可以参考MS Doc了解在Azure Functions中使用 EventProcessor 的更多信息。

英文:

AFAIK, particularly their is no such definite rules(steps to follow) for naming a SeviceBus Trigger or azure function trigger part's of code. It only depends on how we write code for our understanding and for further use of the code.

Actually,

  • EventProcessor is meant for events(request) coming/going from the Service Bus Topic and then transferring information about it by mails or messages or logs to end user(the person it is required to send the information).
  • EventHandler is meant for handling the requests within the scope of your project.

It is good to use the UserCreatedEventProcessor as it is giving clear information on what code is doing and also depends on your project requirement/team understanding.

For further you can refer MS Doc for more information on EventProcessor usage in Azure Functions.

huangapple
  • 本文由 发表于 2023年3月31日 21:51:48
  • 转载请务必保留本文链接:https://go.coder-hub.com/75899324.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定