TAC is a Java-based microservice container that provides support for a series of common development processes such as business code writing, compilation, publishing, JAR dynamic loading and running. It is a new attempt of Tmall App in server-side development mode. TAC is combined with the client framework Tangram to greatly improve development efficiency; TAC is now widely used in tmall App and mobile Taobao special edition.

The beginning of pain – gives birth to the background

The homepage of Tmall App(hereinafter referred to as Mao.com) went from a pit operation in 2015 to a comprehensive personalized service in 2016, when there were more than 50 personalized services on the homepage of Mao.com. Take the home page as an example, in this process, in addition to access the two-party service of shopping guide link, access a large number of three-party services; At the same time, we found:

  • Home page applications are becoming more and more complex and huge. It takes too long to modify the application code, compile and deploy the application code, and most of the time is hard labor.
  • The period for locating faults online is too long. The process from fault discovery to fault location to fault rectification requires the clients, servers, and downstream service providers. If the link length is too long, services cannot be quickly supported.
  • Access to a large number of services leads to frequent deployment on the publishing line. Access to a simple service and modification of a few lines of code lead to the redevelopment, compilation and deployment of the homepage application, affecting the stability of the entire homepage.

At that time, the concept of micro-services was already very popular, and Alibaba also began to vigorously promote Docker (now most apps run on Docker). We thought about the application of the front page of a large split into service, but unlike basic services, the front desk business change fast, frequent changes, break up after the development of students is still face physical labor, such as various services access need maintenance after the split multiple applications at the same time, instead of increased labor costs, so split into micro service way take temporary solution not effect a permanent cure;

The solution — TAC

Under this background, TAC was born. It provides low-cost development and release process, low-cost construction and maintenance of development environment, and high stability guarantee. TAC liberates r&d students from druddy labor and returns to business development through hot deployment. At the same time, once a basic service is connected, it can be provided to multiple businesses. In this mode, fine-grained services can be split, and the change of fault isolation service A does not affect service B.

With the help of TAC, frequently modified new services can be quickly brought online without the need to re-publish the entire application because of a few lines of code or a field change. At the same time, combined with Tangram, realize the page card, pit fast adjustment;

After nearly three years of precipitation, today we release the open source version, which strips the TAC of the group version of Ali related middleware, network, protocol, deployment environment, etc., and retains its core functions. The open source version provides basic capabilities for compiling, hot loading, and running;

TAC Open Source

The system structure

  • The open source version comes in two parts, the TAC container and tac console, and relies on Redis for storage and communication.
  • For simplicity, the container interacts directly with external services only through HTTP;
  • At the same time, in order to improve the development experience, it provides the ability to integrate with GitLab. Users can directly submit codes to GitLab and operate and publish them on the console. Quick validation;

Core class loader

The diagram above shows the tac classloader structure. Each microservice instance on line is loaded by a new classloader, and to make it easier for users to extend new data sources, Extends a classloader on AppClassLoader to load third-party data sources (you can also extend it directly in code, see TAC-Infrastructure);

Quick Start — How to use it

  • Install redis
  • Operation of the container
java -jar tac-container.jar
Copy the code
  • Running the Console
java -jar tac-console.jar --admin
Copy the code
  • You can open the console after success
http://localhost:7001/#/tacMs/list
Copy the code
  • Code development
    • Adding SDK dependencies
<dependency>
    <groupId>com.alibaba</groupId>
    <artifactId>tac-sdk</artifactId>
    <version>${project.version}</version>
</dependency>
Copy the code
  • Write the code
Public class HelloWorldTac implements TacHandler<Object> {/** * private TacLogger TacLogger = TacServiceFactory.getLogger(); /** * write a class that implements the TacHandler interface ** @param context * @return* @throws Exception */ @override public TacResult<Object> execute(Context Context) throws Exception {// Executes the logic tacLogger.info("Hello World");

        Map<String, Object> data = new HashMap<>();
        data.put("name"."hellotac");
        data.put("platform"."iPhone");
        data.put("clientVersion"."7.0.2");
        data.put("userName"."tac-userName");
        returnTacResult.newResult(data); }}Copy the code
  • Local compilation, packaging

  • Release and Testing

  • The official launch

  • Online validation

curl  http://localhost:8001/api/tac/execute/helloworld -s|json
Copy the code
{
  "success": true."msgCode": null,
  "msgInfo": null,
  "data": {
    "helloworld": {
      "data": {
        "name": "hellotac"."clientVersion": "7.0.2"."userName": "tac-userName"."platform": "iPhone"
      },
      "success": true."msCode": "helloworld"}},"hasMore": null,
  "ip": "127.0.0.1"
}
Copy the code

A link to the

  • An apple core
  • TAC
  • Tangram-Android
  • Tangram-iOS