This is a creation in Article, where the information may have evolved or changed.
Some time ago released a small web development project skeleton Morningo, performance and efficiency Fei QI, development speed in a short period of time familiar with the go language should be matched Php,ruby and other such scripting languages, and post-project concurrency performance, basic concurrency to thousands or tens of thousands of TCP connections no problem. However, from the aspect of business architecture, there are many problems in the development of the project, the bottleneck of the database, the high coupling of the monomer project, the poor maintainability and the ductility. Therefore, the early stage of the project can adopt the monolithic architecture, but the latter is still recommended service-oriented distributed architecture. The distributed architecture model, while increasing the amount of code and the cost of inter-service communication, is more resilient and more malleable than the overall project.
Project Address: Https://github.com/chenhg5/ko
Gokit Introduction
The advantages of the go language do not need to repeat, then a go-based microservices framework? Gokit is a go language-related microservices toolkit. It itself toolkit
is called, not framework
. That is, Gokit is a collection of services that provide an interface that allows developers to freely assemble and build their own micro-service projects. Basically, after reading the example of Gokit, you can imitate and write a similar small project. The structure of Gokit is divided into:
Transport
Deciding which way to provide a service request is generally HTTP,RPC
Endpoint
Is the most important layer of gokit, which is an abstract function type that receives a request to return a response. In this type of definition will call the service layer method, assembled into response return. All of the middleware components in Gokit are injected through the decorator design pattern.
type Endpoint func(ctx context.Context, request interface{}) (response interface{}, err error)func(log Logger, in endpoint.Endpoint) endpoint.Endpoint { return func(ctx context.Context, req interface{}) (interface{}, error) { logger.Log("input", toJSON(req)) resp, err := in(ctx, req) logger.Log("output", toJSON(resp), "err", err) return resp, err }}
Service
All of the specific methods are written here and can be understood as part of the controller in a single web framework.
Tool Pack
These three tiers form a gokit microservices application. In addition, as a toolkit, Gokit provides a number of microservices tool components for this purpose.
- Certified components (Basic, JWT)
- Circuit fuse
- Log component
- Prometheus Surveillance System
- Current limiting device
- Service Discovery System Interface (ETCD, consul, etc.)
- Route tracking
- ...
These components greatly facilitate our development of a microservices application.
About KO
Ko is a gokit-based micro-service Architecture application development skeleton. A basic micro-service architecture includes: Distribution Layer API Gateway, monitoring system, log system, service delivery layer, etc. Ko's goal is to provide an architectural reference that reduces the developer's time to get started with the microservices architecture, ultimately to provide a way for developers to architect a formal, fully functional microservices architecture application in a very short period of time, and to start developing business functions right away. At the same time, avoid coupling with a variety of basic services to spend high, provide flexible service customization interface to developers. On the basis of Gokit, KO will provide a decoupled and fully functional API gateway with a fully functional service layer such as data connectivity, as well as command-line scaffolding tools for ancillary project construction. Ko is still in the development of continuous improvement, will update the progress in this article. A traditional basic model architecture diagram is attached.
Resources
[1] https://www.jianshu.com/p/cff ...
[2] https://www.jianshu.com/p/0c3 ...
[3] https://gokit.io/faq/