当需要创建自定义的Spring Boot Starter而不是创建新的微服务时?

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

When it's necessary to create a custom spring boot starter rather than create a new microservice?

问题

我有一个微服务架构,需要一些通用逻辑。
何时需要创建自定义的Spring Boot起动器而不是创建新的微服务?

英文:

I've a microservice architecture, and need some common logic.
When it's necessary to create a custom spring boot starter rather than create a new microservice?

答案1

得分: 1

根据我的经验,从头开始创建一个新的微服务通常是为了防止出现任何庞大的单块应用程序。微服务通常应该只有一个职责,并且要做得很好。您不希望通过添加无关的操作来混淆您的微服务的实现和目的。

有许多关于您可能要创建的“类型”的设计模式,但我不会在这里详细介绍。总的来说,根据您要解决的业务目标,您可以选择您的设计并开始开发。不同的设计应该分开,不应组合成单块样式。这是一篇展示设计选项的好文章:https://www.openlegacy.com/blog/microservices-architecture-patterns/

如果您发现自己不得不重新创建多个为不同用例提供服务的微服务,您总是可以利用诸如Yeoman之类的工具来加速创建这些新项目。您可以构建一个生成器,该生成器将为您提供一个可用的模板,因此您不必每次需要不同服务时都从头开始重新开发。

这是我最近写的一个关于创建您自己的Yeoman生成器的指南:https://medium.com/@dylanlamott/building-a-yeoman-generator-line-by-line-6966debb39a3

英文:

In my experience, creating a new microservice from the ground up is generally due to preventing any monoliths occurring. Microservices should generally have one job and then do it well. You don't want to muddy up the implementation and purpose of your microservice by adding unrelated operations.

There are many design patterns for the "types" you could be creating but I won't go into too much detail there. Overall, based on what business purpose you are solving you can select your design and begin development. Different designs should be separated and not combined into monolithic styles. Here is a good article showcasing design options: https://www.openlegacy.com/blog/microservices-architecture-patterns/

If you find your self having to re-create multiple microservice serving different use cases you can always utilize a tool such as yeoman to speed up creating these new projects. You can build a generator that will give you a working template so you don't have to spend the time re developing from the ground up each time you need a different service.

Here is a guide that I wrote recently on creating your own yeoman generator: https://medium.com/@dylanlamott/building-a-yeoman-generator-line-by-line-6966debb39a3

huangapple
  • 本文由 发表于 2023年6月2日 01:08:35
  • 转载请务必保留本文链接:https://go.coder-hub.com/76384211.html
匿名

发表评论

匿名网友

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

确定