5 Star 21 Fork 7

TarsCloud/Tars.js

Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
Clone or Download
contribute
Sync branch
Cancel
Notice: Creating folder will generate an empty file .keep, because not support in Git
Loading...
README
BSD-3-Clause

Tars.js

With the development of the Internet, more and more services can be carried by not only a single node (or a single language), but also multi-language distributed collaborative development (such as the access layer is completed by Node.js, ) Layer is implemented by C ++ / GO / Python) and from this form a large heterogeneous system.

We developed Tars.js based on the Tars system so that users can quickly build (migrate) Node.js services without changing the overall architecture of heterogeneous systems, and it is very convenient Split the original single service into multiple (logical) subservices.

Tars.js

Tars.js has been accumulated and iterated in Tencent for more than 5 years (supported by the Node.js@0.10 version), and is widely used in Tencent QQ browser, Tencent desktop browser, Tencent map, App treasure, Tencent mobile butler, Internet +, Tens Medical, Tencent Medical, insurance, lottery and other dozens of important businesses, Japan has undertaken tens of billions of traffic.

Tars.js includes the following features:

  • 100% written in JavaScript without any C / C ++ code.
  • Multi-process load balancing and management.
  • Code exception monitoring and restart.
  • Collection and processing of service logs.
  • HTTP (s) service monitoring and usage report automatically, and support user-defined dimension reporting (PP monitoring).
  • Tars (IDL) codec module.
  • Support Tars RPC calling and dyeing (modulo automatic reporting).
  • Support online management command sending and pull service configuration.
  • Original LongStackTrace ™ exception tracking mechanism.
  • ...... More features can be found at [@ tars / node-agent] (https://www.npmjs.com/package/@tars/node-agent)

design concept

High degree of freedom

  • Compatible with all (≥0.10) official Node.js versions.
  • No intrusion or modification to Node.js source code.
  • The bottom layer is completely transparent to the upper layer and supports a variety of upper-level frameworks, without changes.

In other words:

You can use any framework you are familiar with (such as Express.js / Koa.js, including but not limited to web frameworks), and you don't need to modify the framework (without introducing any middleware). You can run it through Tars.js and enjoy the various monitoring and management features provided by the platform.

At the same time, the modules provided by Tars.js can also be imported according to your needs (or not imported if not used).

High performance

Tars.js is designed for high performance and large concurrency, and uses a large number of front-end (V8) optimization techniques (such as FlattenString / FastProperties, etc.) to minimize the impact of the capabilities provided on business performance.

After our testing (Web Server), the default impact of bypass reporting and monitoring on service performance is ≤ 5%, and the performance of commonly used modules (RPC, logs, etc.) is among the best in the industry.

Differentiation

Tars.js provides differentiated operation solutions according to different business types:

  • High-traffic services: Try to reduce the impact of the framework on business performance.
  • Low-traffic business: make full use of hardware resources to improve development experience.

List of available modules

Due to the limited space, I can't show all the capabilities. If you have more requirements (such as RPC calls, etc.), you can use the modules provided by Tars.js (as follows):

  • @ tars/stream: Tars (Tup) protocol codec module can be combined with tars2node.
  • @ tars/rpc: Tars RPC calling module.
  • @ tars/logs: Log component, including rolling (by size, time) and remote logs.
  • @ tars/config: Used to obtain service configuration files online.
  • @ tars/monitor: Provides support for service monitoring, feature monitoring, and PP monitoring reporting.
  • @ tars/notify: Used to report service (alarm) messages.
  • @ tars/utils: A collection of auxiliary tools, including Tars configuration files and Tars RPC Endpoint parser.
  • @ tars/dyeing: Tars RPC dyeing definition module.
  • @ tars/registry: Used for Tars name service query (Servant ===> Endpoint).

Each module (click the name to jump) has extremely detailed documentation (README) for you to consult at any time.

Hello World

  1. On the Tars platform-> Service Management-> Service Go Online, launch a new service:
  • Basic service information:
  • Service Name: HelloWorld
  • Service Type: NODEJS
  • Template name: tars.cloud.default
  • OBJ deployment information:
  • OBJ name: HttpObj
  • Yes TARS: Select No (remove check box)
  • Port: Automatically generated port
  1. Install the @ tars/deploy packaging tool.
npm i -g @ tars / deploy
  1. Choose the framework based on your business needs and your preferences (!Tars.js does not limit the framework you use!), Write your business code:
const http = require('http');

const hostname = process.env.IP || '127.0.0.1';
const port = process.env.PORT || 3000;

const server = http.createServer((req, res) => {
  res.statusCode = 200;
  res.setHeader('Content-Type', 'text/plain');
  res.end('Hello World\n');
});

server.listen(port, hostname, () => {
  console.log(`Server running at http://${hostname}:${port}/`);
});

The above is an example of HTTP Server on the official website of Node.js. It only needs to modify the IP and port to run on the Tars.js platform. The IP and PORT obtained in the environment variables here are the IP and port in the OBJ deployment information you configured in the first step.

  1. Execute the packaging tool in the project root directory to generate the release package HelloWorld.tgz:
tars-deploy HelloWorld
  1. On the Tars platform, select the service you just created-> Release Management-> Manually upload the release package, and then publish this version.

  2. You can access your services through the IP and port you configured in the first step.

BSD 3-Clause License Copyright (c) 2018, All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

About

基于 Tars 体系研发出 Tars.js 以便用户在不改变异构系统整体架构的情况下快速搭建(迁移) Node.js 服务,并可非常方便的将原来的单一服务拆分为多个(逻辑)子服务 expand collapse
JavaScript
BSD-3-Clause
Cancel

Releases

No release

Contributors

All

Activities

Load More
can not load any more
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/TarsCloud/Tars.js.git
git@gitee.com:TarsCloud/Tars.js.git
TarsCloud
Tars.js
Tars.js
master

Search