Table of Contents generated with DocToc
- Important note
- Official document
- Concept
- Features
- Examples
- Quick Start for Gin
- Development Status: Stable
- Build instruction
- Test instruction
- Contributing
The version of v1.3.X imported rk-gin, rk-echo, rk-grpc and rk-gf in the go.mod file initially. User only needs to [go get rk-boot] for starting web framework.
From v1.4.X, rk-boot will not include those dependencies in one place.
Instead, we use multi-module repository for supported web frameworks.
Release Description Example v1.4.x Use multi-module repository, [go get] submodule as needed for web frameworks go get github.com/rookie-ninja/rk-boot/gin v1.3.x Use root-module repository, will import all web frameworks, not suggested! go get github.com/rookie-ninja/rk-boot The version of submodule will follow version of rk-xxx dependencies.
For example, rk-grpc is currently at release of v1.2.15, so the latest version of submodule would be github.com/rookie-ninja/rk-boot/grpc@v1.2.15
rk-boot is a library which support bootstrapping server at runtime via YAML file. It is a little like spring boot way.
We hope user can achieve bellow goals while designing/implementing microservice.
- 1: Decide which dependencies to use. (For example, MySQL, Redis, AWS, Gin are the required dependencies.)
- 2: Add dependencies in boot.yaml (where rk-boot will automatically initiate dependency client instances.)
- 3: Implement your own codes (without caring about logging, metrics and tracing of dependency client.)
- 4: Monitor service and dependency (via a standard dashboard.)
We are planning to achieve this goal by unify dependency input(by boot.yaml) and output(logging format, metrics format etc).
We will add more bootstrapper for popular third-party dependencies.
- Build application with unified project layout at enterprise level .
- Build API with the unified format of logging, metrics, tracing, authorization at enterprise level.
- Make application replace core dependencies quickly.
- Save learning time of writing initializing procedure of popular frameworks and libraries.
- User defined Entry for customization.
Welcome to contribute your web framework dependencies into rk-boot family.
Start with docs and refer rk-gin as example.
| Frameworks | Status | Tag | Installation | Dependency |
|---|---|---|---|---|
| gin-gonic/gin | Stable | v1.2.22 | go get github.com/rookie-ninja/rk-boot/gin | rk-gin |
| gRPC | Stable | v1.2.25 | go get github.com/rookie-ninja/rk-boot/grpc | rk-grpc |
| labstack/echo | Stable | v0.0.16 | go get github.com/rookie-ninja/rk-boot/echo | rk-echo |
| gogf/gf | Stable | v0.0.15 | go get github.com/rookie-ninja/rk-boot/gf | rk-gf |
| gofiber/fiber | Testing | v0.0.11 | go get github.com/rookie-ninja/rk-boot/fiber | rk-fiber |
| zeromicro/go-zero | Testing | v0.0.11 | go get github.com/rookie-ninja/rk-boot/zero | rk-zero |
| gorilla/mux | Testing | v0.0.9 | go get github.com/rookie-ninja/rk-boot/mux | rk-mux |
Databases still in Testing stage. Please see examples for detail.
| Database | Status | Tag | ORM | Installation | Dependency |
|---|---|---|---|---|---|
| MySQL | Stable | v0.0.6 | gorm | go get github.com/rookie-ninja/rk-db/mysql | rk-db/mysql |
| SQLite | Stable | v0.0.4 | gorm | go get github.com/rookie-ninja/rk-db/sqlite | rk-db/sqlite |
| SQL Server | Stable | v0.0.4 | gorm | go get github.com/rookie-ninja/rk-db/sqlserver | rk-db/sqlserver |
| postgreSQL | Stable | v0.0.4 | gorm | go get github.com/rookie-ninja/rk-db/postgres | rk-db/postgres |
| ClickHouse | Stable | v0.0.4 | gorm | go get github.com/rookie-ninja/rk-db/clickhouse | rk-db/clickhouse |
| Name | Type | Example | Docs |
|---|---|---|---|
| gin-gonic/gin | Web Framework | example | docs |
| gRPC | Web Framework | example | docs |
| labstack/echo | Web Framework | example | docs |
| gogf/gf | Web Framework | example | docs |
| gofiber/fiber | Web Framework | example | docs |
| zeromicro/go-zero | Web Framework | example | docs |
| gorilla/mux | Web Framework | example | docs |
| MySQL | ORM - gorm | example | docs |
| SQLite | ORM - gorm | example | docs |
| SQL Server | ORM - gorm | example | docs |
| postgreSQL | ORM - gorm | example | docs |
| ClickHouse | ORM - gorm | example | docs |
We will start gin-gonic/gin server with rk-boot.
- Installation
go get github.com/rookie-ninja/rk-boot/gin
- boot.yaml
---
gin:
- name: greeter # Required
port: 8080 # Required
enabled: true # Required
sw:
enabled: true # Optional, enable swagger UI via /sw by default
commonService:
enabled: true # Optional, enable common API like /rk/v1/healthy
tv:
enabled: true # Optional, enable RK TV via /rk/v1/tv- main.go
// Copyright (c) 2021 rookie-ninja
//
// Use of this source code is governed by an Apache-style
// license that can be found in the LICENSE file.
package main
import (
"context"
"github.com/gin-gonic/gin"
"github.com/rookie-ninja/rk-boot"
"github.com/rookie-ninja/rk-boot/gin"
"net/http"
)
// Application entrance.
func main() {
// Create a new boot instance.
boot := rkboot.NewBoot()
// Register handler
ginEntry := rkbootgin.GetGinEntry("greeter")
ginEntry.Router.GET("/v1/greeter", func(ctx *gin.Context) {
ctx.JSON(http.StatusOK, "Hello!")
})
// Bootstrap
boot.Bootstrap(context.Background())
// Wait for shutdown sig
boot.WaitForShutdownSig(context.Background())
}- validate
$ go run main.go
$ curl -X GET localhost:8080/rk/v1/healthy
{"healthy":true}
$ curl -X GET localhost:8080/v1/greeter
Hello!- Swagger: http://localhost:8080/sw
Simply run make all to validate your changes. Or run codes in example/ folder.
- make all If proto or files in boot/assets were modified, then we need to run it.
Run unit test with make test command.
github workflow will automatically run unit test and golangci-lint for testing and lint validation.
We encourage and support an active, healthy community of contributors — including you! Details are in the contribution guide and the code of conduct. The rk maintainers keep an eye on issues and pull requests, but you can also report any negative conduct to lark@rkdev.info.
Released under the Apache 2.0 License.


