1. 程式人生 > >Spring Cloud就是一個“路由”?

Spring Cloud就是一個“路由”?

 

Spring Cloud到底是什麼?

舉例,比如說

一個普通的HTTP API(或者叫WEB API或者Restful API)
是這樣的:
http://127.0.0.1:8081/entity1/getEntity1
http://127.0.0.1:8082/entity2/getEntity2

對比一下,
在SpringCloud裡面,就換成了這個樣子:
http://app_name1/entity1/getEntity1
http://app_name2/entity2/getEntity2

========== ==========


服務不一定是HTTP/REST,也可能是Thrift、Kafka

假設現在有四個微服務:使用者系統、訂單系統、支付系統、快遞系統
這四個微服務分別使用 HTTP, REST, Thrift, Kafka 來呼叫
後期可能:新增微服務;減少微服務;或者更換微服務的呼叫方式

Spring Cloud的作用就是把這些微服務統一為一個appname,
然後繫結到 協議+地址+埠+API。

示意圖:

外部訪問 -> SpringCloud路由 -> 應用程式API(微服務)


========== ==========

好像和某個東西有點像。就是微軟2005年釋出的WCF框架。

========== ==========

Spring Cloud和WCF做的事情差不多,區別在於:
Spring Cloud 僅僅是隻簡單的完成了一個“路由”的功能;

--