1
0
mirror of https://github.com/go-kratos/kratos.git synced 2025-01-10 00:29:01 +02:00
Your ultimate Go microservices framework for the cloud-native era.
Go to file
Windfarer a500fe2f0d
Cmd use GOMODCACHE env (#733)
* use cache path
2021-03-02 23:02:13 +08:00
.github Revert "update workflow" (#723) 2021-02-24 16:27:08 +08:00
api init v2 2021-02-17 17:14:47 +08:00
cmd Cmd use GOMODCACHE env (#733) 2021-03-02 23:02:13 +08:00
config Update README.md 2021-02-20 21:24:35 +08:00
docs init v2 2021-02-17 17:14:47 +08:00
encoding init v2 2021-02-17 17:14:47 +08:00
errors init v2 2021-02-17 17:14:47 +08:00
internal init v2 2021-02-17 17:14:47 +08:00
log add logger wrapper (#715) 2021-02-22 17:50:43 +08:00
metrics init v2 2021-02-17 17:14:47 +08:00
middleware display error messages (#727) 2021-02-25 09:43:49 +08:00
registry fix to discoverer 2021-02-28 15:32:45 +08:00
third_party init v2 2021-02-17 17:14:47 +08:00
transport rename naming 2021-02-28 20:40:05 +08:00
.gitignore init v2 2021-02-17 17:14:47 +08:00
app_test.go init v2 2021-02-17 17:14:47 +08:00
app.go rename naming 2021-02-28 20:40:05 +08:00
go.mod init v2 2021-02-17 17:14:47 +08:00
go.sum init v2 2021-02-17 17:14:47 +08:00
LICENSE init v2 2021-02-17 17:14:47 +08:00
options.go rename naming 2021-02-28 20:40:05 +08:00
README_zh.md add ENG readme (#725) 2021-02-24 21:58:44 +08:00
README.md Update README.md 2021-02-24 22:27:54 +08:00

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, you can get rid of most issues you might encounter in the field of distributed systems and software engineering, so that you can focus on business delivery. For each developer, Kratos is an ideal one for learning as well. You can navigate the diverse knowledge of microservice and accumulate engineering experience.

Principles

  • Simple: Appropriate design, plain and simple code.
  • General: Cover the various utilities for business development.
  • Reliable: Higher testability and greater test coverage of base libs validated in the production environment.
  • Robust: Base libs are designed reasonably to reduce misuse.
  • High-performance: We give you optimal performance without using the hack-way approach like adding the unsafe package and guarantee compatibility and stability at the same time.
  • Expandable: Appropriate API design, 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 cache code generation, lint tools, etc.

Features

  • APIs: HTTP/gRPC based transport and Protobuf defined communication protocol.
  • Errors: We use ProtoBuf Enum to define error code and generate error handle code.
  • Metadata: Normalize the service metadata transmission by excellent middleware.
  • Config: Multi-data source Support, well arranged, dynamic configuration via Atomic package.
  • Logger: Standard log API, easily integrate with third-party log lib, Fluentd logs collection.
  • Metrics: Prometheus integration by default. Furthermore, with the unified Metrics interface, you can implement your metrics system more flexible
  • Tracing: Complete micro-service link tracing followed by OpenTracing specification.
  • Encoding: Support Accept and Content-Type for auto content encoding.
  • Transport: Common HTTP/ GRPC transport layer offers you powerful Middleware support.
  • Registry: One pluggable API for the different registry.

Getting Started

Required

Installing

go get github.com/go-kratos/kratos/cmd/kratos/v2@latest

Create a service

# create project template
kratos new helloworld

cd helloworld
# 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 ./...
# compile
go build -o ./bin/ ./...
# run
./bin/helloworld -conf ./configs

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

License

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