kratos

module
v0.0.0-...-43e5fc7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 12, 2022 License: MIT

README

kratos

COPY FROM BILIBILI

Language GoDoc

Kratos

Kratos是bilibili开源的一套Go微服务框架,包含大量微服务相关框架及工具。

名字来源于:《战神》游戏以希腊神话为背景,讲述由凡人成为战神的奎托斯(Kratos)成为战神并展开弑神屠杀的冒险历程。

Features

  • HTTP Blademaster:核心基于gin进行模块化设计,简单易用、核心足够轻量;
  • GRPC Warden:基于官方gRPC开发,集成discovery服务发现,并融合P2C负载均衡;
  • Cache:优雅的接口化设计,非常方便的缓存序列化,推荐结合代理模式overlord
  • Database:集成MySQL/HBase/TiDB,添加熔断保护和统计支持,可快速发现数据层压力;
  • Config:方便易用的paladin sdk,可配合远程配置中心,实现配置版本管理和更新;
  • Log:类似zap的field实现高性能日志库,并结合log-agent实现远程日志管理;
  • Trace:基于opentracing,集成了全链路trace支持(gRPC/HTTP/MySQL/Redis/Memcached);
  • Kratos Tool:工具链,可快速生成标准项目,或者通过Protobuf生成代码,非常便捷使用gRPC、HTTP、swagger文档;

Quick start

Requirments
  • Go version>=1.13
  • 设置环境变量:
  • 开启go mod:GO111MODULE=on
  • 设置包下载代理:GOPROXY=https://goproxy.cn,direct
  • 代理忽略公司git地址:GONOPROXY=git.huoys.com
  • 关闭校验:GOSUMDB=off
  • 设置GOFLAGS:GOFLAGS="-mod=mod"
Required

需要安装好对应的依赖环境,以及工具:

Installation

1.安装工具:

   - 通过go get安装:

     ```shell
     go get -u gitlab.com/firerocksg/xy3-kratos/tool/kratos@master

     ```

   - 安装全部工具

     ```shell
     kratos tool install all
     ```

   - 安装protobuf
  1. 生成基于kratos库的脚手架工程:

    • 一键生成服务工程项目:

      kratos new [servcieName]
      
    • 一键生成游戏工程项目:

      kratos new [gameName] --game
      
Build & Run
 cd [servcieName]
---
 kratos run
或
 cd [servcieName]/cmd
 go build
 ./cmd -conf ../configs
---

Directories

Path Synopsis
example
pkg
cache/memcache/test
Package proto is a generated protocol buffer package.
Package proto is a generated protocol buffer package.
cache/redis
Package redis is a client for the Redis database.
Package redis is a client for the Redis database.
conf/dsn
Package dsn implements dsn parse with struct bind
Package dsn implements dsn parse with struct bind
conf/env
Package env get env & app config, all the public field must after init() finished and flag.Parse().
Package env get env & app config, all the public field must after init() finished and flag.Parse().
container/group
Package group provides a sample lazy load container.
Package group provides a sample lazy load container.
log
Package log 是kratos日志库.
Package log 是kratos日志库.
log/internal/core
Package core houses zap's shared internal buffer pool.
Package core houses zap's shared internal buffer pool.
net/http/blademaster/binding/example
Package example is a generated protocol buffer package.
Package example is a generated protocol buffer package.
net/http/blademaster/render
Package render is a generated protocol buffer package.
Package render is a generated protocol buffer package.
net/rpc/warden/internal/benchmark/bench/proto
Package grpc is a generated protocol buffer package.
Package grpc is a generated protocol buffer package.
net/rpc/warden/internal/proto/testproto
Package testproto is a generated protocol buffer package.
Package testproto is a generated protocol buffer package.
str
sync/errgroup
Package errgroup provides synchronization, error propagation, and Context errgroup 包为一组子任务的 goroutine 提供了 goroutine 同步,错误取消功能.
Package errgroup provides synchronization, error propagation, and Context errgroup 包为一组子任务的 goroutine 提供了 goroutine 同步,错误取消功能.
tool
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL