If you search for "interface access layer" from Baidu, you will find that the main is. NET inside the technology, called Idal, is actually the data access layer interface. Its main function is to be compatible with a variety of databases. For example, if you define a standard interface and then implement SQL Server access and Oracle access to the interface, you can freely switch the database using Idal. See. NET DEMO PETSHOP4, with a total of 22 items. The general idea is 3 layers, from model, DAL, BLL, and then he used the Factory mode on each layer, the logic and implementation want to separate, such as before the BLL directly call DAL is good, but now the BLL is called Idal,idal is an interface layer, which encapsulates some business logic to complete, The specific implementation is given to the DAL to achieve, and then through the Factory mode Dalfactory and mapping to complete the Idal layer class instantiation.
The interface access layer referred to by the Spore (SPORE) framework is probably the same concept as ial, except that this concept is used for inter-service calls rather than databases. But at first the idea was inspired by Shenli's article, "Micro-SOA: Principles of Service design and practices", which was thought of in conjunction with other ideas. The idea is only a utility model at present, the specific use of the effect also needs further verification, but only for the small and medium-sized development team, in the early implementation of the micro-service can completely replace the API gateway. is a comparison of the capabilities, implementation technologies, and development difficulties of the ESB, MicroServices API Gateway, and ial:
|
function |
Implementation technology |
Development difficulty factor |
ESB |
Service registration, routing, load balancing, authorization, monitoring, multiple protocol integrations |
C + +, Epoll |
Ten |
API GateWay |
Authorization, monitoring, routing, caching |
Go language or Nodejs |
5 |
Ial+nginx |
Routing, load balancing, authorization, monitoring, multiple protocol integration |
Java, spring AOP |
1 |
As you can see from the table, the three are actually similar in function. But the most difficult thing to do technically is to ial the ESB, the simplest. It's hard to say what technology is used by specific ESBs, because most of the domestic use of open source ESBs or the use of foreign third-party products. I guess the ESB should be implemented in a way similar to the implementation of the online game gateway, which is to use C + + to call the Linux Epoll (or Windows completion port) to accomplish high concurrency. Of course Nodejs is also called Epoll to complete high concurrency, but the Nodejs package is much simpler. We see that Ial uses the simplest Java basic syntax plus Spring AOP (which is not technically available) to accomplish the same functionality as an ESB. Such as:
It is also not difficult to see from the diagram above that if the user calls ial in a way called by the API in-process, then ial is a bit like an API gateway or an ESB. Of course, because the latter needs to deal with high concurrency, you do not have to do so, you also need to add a layer of high concurrency processing shell. Ial How does the ESB and API gateway perform similar functions, such as authorization, monitoring? Mainly through the spring AOP technology, before explaining this, let's first look at how ial is implemented.
The first step defines the standard interface:
Public Interface Sporeservice {
Public List<spore> FindByID (Long ID);
Public void Update (spore spore);
}
The second step is to implement this interface by protocol (a bit like crap), and here is the rest protocol to implement the interface:
Public class Sporeservicerestproxy implements Sporeservice {
......
}
You can also define an interface implementation for thrift:
Public class Sporeservicethriftproxy implements Sporeservice {
......
}
The third step is to use Spring AOP to intercept all interfaces and write processing modules.
This is done. If an interface visitor needs to invoke an interface simply inject Sporeservice to perform some object-oriented operations. AOP enables functions such as authorization, monitoring, caching, and multiple protocol integration. Multiple protocol integration is needless to say, because the interface has just been defined in the way it has been implemented. Authorization, monitoring, and caching can define related annotations and then use AOP to intercept and process:
Public class Sporeservicerestproxy implements Sporeservice {
@Cache ({"Type_update"})//cache operation annotations
@Log ({"Type_fund"})//capture log annotations
@Secured ({"Role_spitter", "Role_admin"})//authorization annotations
@Override
Public void Update (spore spore) {}
}
When you annotate and use AOP to intercept annotations, you actually form a processing pipeline where you can add any macro functionality you want to handle. And these macro functions can also be done here without processing, forwarding it to a service, in order to achieve separation of responsibilities design. such as authorization, you only need to submit the authorization information to the authorization service in the AOP module, and then you can get the result. Log capture you only need to send the information to the message queue to finish, the rest of the log processing service to listen to processing. As for the service registration function mentioned in the ESB, it is impossible to implement in ial, it needs to be implemented by the interface publishing module, and the interface publishing module can write its own code (or configuration file) for service registration.
In addition, we say that the whole system is to support high concurrency, then the ial will affect the high concurrency, which is not. If a system at full load operation, only two services, each service support 1000 concurrent, add API Gateway, API gateway to support at least 2000 of the concurrency, the original concurrency is unchanged, it does not affect concurrency; After adding ial, ial and clients are in-process calls, Or is equal to the client's direct access to the service, or 2000 concurrency, plus equals no plus, does not affect concurrency.
In fact, the most important function of the original ESB is routing and load balancing (similar to Nginx,nginx if you add authorization, audit these functions into the web domain of the ESB), but now these are not things, because there are a lot of technology can do, such as the rest interface you can do with Nginx, Thrift interface You can do with zookeeper and so on. So theoretically ial+nginx can realize the many functions of the ESB, the key is that the former is too simple, and does the separation of duties.
Spore Framework-Interface access layer, ESB, microservices API Gateway Comparison