You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
longxboy 6f1640b81d
add url for docs (#1147)
3 years ago
.github fix data race (#963) 4 years ago
api Feat/fix examples (#1129) 3 years ago
cmd kratos run command support to find the cmd directory from the parent directory (#1146) 3 years ago
config fix config decoder (#1142) 3 years ago
docs init v2 4 years ago
encoding add form encoding (#1138) 3 years ago
errors fix(http): fix error encoder (#1141) 3 years ago
examples fix(http): fix error encoder (#1141) 3 years ago
internal Feat/fix examples (#1129) 3 years ago
log change debug level to -1 (#1105) 3 years ago
metadata add range (#1052) 3 years ago
metrics init v2 4 years ago
middleware add response header (#1119) 3 years ago
registry fix nacos 4 years ago
third_party add error third party (#1114) 3 years ago
transport fix(http): fix error encoder (#1141) 3 years ago
.gitignore init v2 4 years ago
LICENSE init v2 4 years ago
Makefile add source code installing (#1113) 3 years ago
README.md add url for docs (#1147) 3 years ago
README_zh.md add url for docs (#1147) 3 years ago
ROADMAP.md roadmap: update roadmap progress (#828) 4 years ago
SECURITY.md Create SECURITY.md 4 years ago
app.go Revert/root ctx v2 (#1088) 3 years ago
app_test.go init v2 4 years ago
go.mod add form encoding (#1138) 3 years ago
go.sum add form encoding (#1138) 3 years ago
options.go add feat endpoint (#972) 4 years ago

README.md

kratos

Language Build Status GoDoc Go Report Card Discord

Translations: English | 简体中文

Kratos

Kratos is a microservice-oriented governance framework implements by golang, which offers convenient capabilities to help you quickly build a bulletproof application from scratch.

The name is inspired by the game God of War which is based on Greek myths, tells the Kratos from mortals to become a God of War and launches the adventure of killing god.

Goals

Kratos boosts your productivity. With the integration of excellent resources and further support, programmers can get rid of most issues might encounter in the field of distributed systems and software engineering such that they are allowed to focus on the release of businesses only. Additionally, for each programmer, Kratos is also an ideal one learning warehouse for many aspects of microservices to enrich their experiences and skills.

Principles

  • Simple: Appropriate design, plain and easy code.
  • General: Cover the various utilities for business development.
  • Highly efficient: Speeding up the efficiency of businesses upgrading.
  • Stable: The base libs validated in the production environment which have the characters of the high testability, high coverage as well as high security and reliability.
  • Robust: Eliminating misusing through high quality of the base libs.
  • High-performance: Optimal performance excluding the optimization of hacking in case of unsafe. 
  • Expandability: Properly designed interfaces, you can expand utilities such as base libs to meet your further requirements.
  • Fault-tolerance: Designed against failure, enhance the understanding and exercising of SRE within Kratos to achieve more robustness.
  • Toolchain: Includes an extensive toolchain, such as the code generation of cache, the lint tool, and so forth.

Features

  • APIs: The communication protocol is based on the HTTP/gRPC through the definition of Protobuf.
  • Errors: Both the definitions of error code and the handle interfaces of code generation for tools are defined by the Enum of the Protobuf.
  • Metadata: In the protocol of HTTP/gRPC, the transmission of service atomic information are formalized by the Middleware.
  • Config: Multiple data sources are supported for configurations and integrations such that dynamic configurations are offered through the manner of Atomic operations.
  • Logger: The standard log interfaces ease the integration of the third-party log libs and logs are collected through the Fluentd.
  • Metrics: Prometheus integrated by default. Furthermore, with the uniform metric interfaces, you can implement your own metric system more flexible.
  • Tracing: The OpenTelemetry is conformed to achieve the tracing of microservices chains.
  • Encoding: The selection of the content encoding is automatically supported by Accept and Content-Type.
  • Transport: The uniform plugins for Middleware are supported by HTTP/gRPC.
  • Registry: The interfaces of the centralized registry is able to be connected with various other centralized registries through plug-ins.
  • Validation: Verification rules defined in Protobuf can be supported by HTTP/gRPC service.
  • SwaggerAPI: Swagger API generated Automatically and embed Swagger UI endpoint can be started by adding Swagger plugin.

Getting Started

Required

Installing

install from go get:
go get github.com/go-kratos/kratos/cmd/kratos/v2@latest
kratos upgrade
install from source code:
git clone https://github.com/go-kratos/kratos
cd kratos
make install

Create a service

# create project template
kratos new helloworld

cd helloworld
# download modules
go mod download

# generate Proto template
kratos proto add api/helloworld/helloworld.proto
# generate Proto source code
kratos proto client api/helloworld/helloworld.proto
# generate server template
kratos proto server api/helloworld/helloworld.proto -t internal/service

# generate all proto source code, wire, etc.
go generate ./...

# run
kratos run

Kratos Boot

import "github.com/go-kratos/kratos/v2"
import "github.com/go-kratos/kratos/v2/transport/grpc"
import "github.com/go-kratos/kratos/v2/transport/http"

httpSrv := http.NewServer(http.Address(":8000"))
grpcSrv := grpc.NewServer(grpc.Address(":9000"))

app := kratos.New(
    kratos.Name("kratos"),
    kratos.Version("latest"),
    kratos.Server(httpSrv, grpcSrv),
)
app.Run()

Community

Conventional commits

The structure of the commit message should look like the following

<type>[optional scope]: <description>

[optional body]

[optional footer(s)]

The information should be commit in the following format:

  • fix: simply describe the problem that has been fixed
  • feat(log): simple describe of new features
  • deps(examples): simple describe the change of the dependency
  • break(http): simple describe the reasons for breaking change

License

Kratos is MIT licensed. See the LICENSE file for details.

Contributors

Thanks for their outstanding contributions.