关于service概念的存在不是十分理解 #5545
Unanswered
Lewisyixin
asked this question in
Q&A
Replies: 2 comments 2 replies
-
Service is an abstraction of route. If you want to reuse some of the configurations on the route, you can abstract them into a service. |
Beta Was this translation helpful? Give feedback.
2 replies
-
同一个upstream提供多个接口的情况还是有的啊,路由如果都有 /* 这种模糊匹配那一个route就够了,但是很多时候接口可能需要有不同的权限限制,就得单独抽出来成为route,而不能都丢到/* 下面,这时候service就可以被复用了。 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
我理解service= upstream + 域名匹配 + 插件
创建route的时候可以绑定service
但是我理解通常情况下 域名+route确定一个接口的后端转发,也就是upstream,所以当一个service指定了域名的情况下,他如何被复用呢?
举个例子:
我定义了一个serviceA,后端的upstream是机器hostA,匹配的域名是 www.test.com
此时我创建了一个route: /routeA,绑定了serviceA,此时 访问www.test.com/routeA ,可以访问到hostA机器对吧,
如果我想复用这个serviceA,我创建另一个route: /routeB,此时访问www.test.com/routeA和www.test.com/routeB都能请求到hostA,
但是我理解正常的开发模式中,这种一个域名不同uri访问都同一个upstream的情景应该很少吧?更多的情况不应该是不同域名的同一个route访问到同一个upstream吗,例如
www.test1.com/commonapi和www.test2.com/commonapi 这两个域名都存在一个route去访问一个通用api的模块,我理解这种使用模式不是会更常见一些吗?
所以不是很理解service这个概念更适合在哪种场景下使用呢?
Beta Was this translation helpful? Give feedback.
All reactions