Popularity
1.8
Growing
Activity
7.9
-
18
1
2

Programming language: Go
License: Apache License 2.0
Tags: Web Frameworks    

rk-boot alternatives and similar packages

Based on the "Web Frameworks" category.
Alternatively, view rk-boot alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of rk-boot or a related project?

Add another 'Web Frameworks' Package

README

rk-boot

build codecov Go Report Card License

Bootstrapper for rkentry.Entry. With rk-boot, users can start grpc, gin, prometheus client or custom entry service with yaml formatted config file. Easy to compile, run and debug your grpc service, grpc gateway, swagger UI and rk-tv web UI.

<!-- START doctoc generated TOC please keep comment here to allow auto update --> <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --> Table of Contents generated with DocToc

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

Online document

rkdev.info

Concept

rk-boot is a library which support bootstrapping server at runtime. It is a little like spring boot way.

Why do I want it?

  • 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.

[arch](img/boot-arch.png)

Installation

go get -u github.com/rookie-ninja/rk-boot

Quick Start

There are two ways users can run gRpc or Gin service. one is yaml formatted config file. The other one is through golang code.

Start gin server from YAML

---
gin:
  - name: greeter
    port: 8080
    sw:
      enabled: true     # Enable swagger UI
    commonService:
      enabled: true     # Enable common service
    tv:
      enabled:  true    # Enable RK TV
package main

import (
    "context"
    "github.com/rookie-ninja/rk-boot"
)

func main() {
    // Create a new boot instance.
    boot := rkboot.NewBoot()

    // Bootstrap
    boot.Bootstrap(context.Background())

    // Wait for shutdown sig
    boot.WaitForShutdownSig(context.Background())
}

```shell script $ go run main.go $ curl -X GET localhost:8080/rk/v1/healthy {"healthy":true}

- Swagger: http://localhost:8080/sw
![gin-sw](img/gin-sw.png)

- TV: http://localhost:8080/rk/v1/tv
![gin-tv](img/gin-tv.png)

### Start grpc server from YAML
```yaml
---
grpc:
  - name: greeter       # Name of grpc entry
    port: 1949          # Port of grpc entry
    reflection: true    # Enable grpc server reflection, https://github.com/grpc/grpc/blob/master/doc/server-reflection.md
    commonService:
      enabled: true     # Enable common service
    gw:
      enabled: true     # Enable grpc-gateway, https://github.com/grpc-ecosystem/grpc-gateway
      port: 8080        # Port of grpc-gateway
      tv:
        enabled: true   # Enable RK TV
      sw:
        enabled: true   # Enable Swagger UI
package main

import (
    "context"
    "github.com/rookie-ninja/rk-boot"
)

// Application entrance.
func main() {
    // Create a new boot instance.
    boot := rkboot.NewBoot()

    // Bootstrap
    boot.Bootstrap(context.Background())

    // Wait for shutdown sig
    boot.WaitForShutdownSig(context.Background())
}

```shell script $ go run main.go $ curl -X GET localhost:8080/rk/v1/healthy {"healthy":true}

- Swagger: http://localhost:8080/sw
![grpc-sw](img/grpc-sw.png)

- TV: http://localhost:8080/rk/v1/tv
![grpc-tv](img/grpc-tv.png)

## Gin middleware
rk-boot depends on rk-gin which contains some commonly used middlewares can be used with gin framework directly. 
[rk-gin](https://github.com/rookie-ninja/rk-gin)
- logging middleware
- prometheus metrics middleware
- auth middleware
- tracing middleware
- panic middleware
- metadata middleware

### Logging middleware
**No codes needed!**

Enable middleware in boot.yaml file as bellow.
Please refer [online docs](https://rkdev.info/docs) for details.

```yaml
gin:
  - name: greeter                             # Required
    port: 8080                                # Required
    commonService:                            # Optional
      enabled: true                           # Optional, default: false
    interceptors:                             # Optional
      loggingZap:
        enabled: true                         # Enable logging middleware

```shell script $ go run main.go $ curl -X GET localhost:8080/rk/v1/healthy {"healthy":true}

```shell script
# logs would be printed as bellow.
------------------------------------------------------------------------
endTime=2021-07-05T23:42:35.588164+08:00
startTime=2021-07-05T23:42:35.588095+08:00
elapsedNano=69414
timezone=CST
ids={"eventId":"9b874eea-b16b-4c46-b0f5-d2b7cff6844e"}
app={"appName":"rk-demo","appVersion":"master-f414049","entryName":"greeter","entryType":"GinEntry"}
env={"arch":"amd64","az":"*","domain":"*","hostname":"lark.local","localIP":"10.8.0.2","os":"darwin","realm":"*","region":"*"}
payloads={"apiMethod":"GET","apiPath":"/rk/v1/healthy","apiProtocol":"HTTP/1.1","apiQuery":"","userAgent":"curl/7.64.1"}
error={}
counters={}
pairs={}
timing={}
remoteAddr=localhost:56274
operation=/rk/v1/healthy
resCode=200
eventStatus=Ended
EOE

Other middleware

Please refer online docs

Grpc interceptor

rk-boot depends on rk-grpc which contains some commonly used middlewares can be used with gin framework directly. rk-grpc

  • logging interceptor
  • prometheus metrics interceptor
  • auth interceptor
  • tracing interceptor
  • panic interceptor
  • metadata interceptor

Logging interceptor

---
grpc:
  - name: greeter                   # Name of grpc entry
    port: 1949                      # Port of grpc entry
    commonService:
      enabled: true                 # Enable common service for testing
    gw:
      enabled: true                 # Enable grpc-gateway, https://github.com/grpc-ecosystem/grpc-gateway
      port: 8080                    # Port of grpc-gateway
    interceptors:
      loggingZap:
        enabled: true

```shell script $ go run main.go $ curl -X GET localhost:8080/rk/v1/healthy {"healthy":true}

```shell script
# logs would be printed as bellow.
------------------------------------------------------------------------
endTime=2021-07-09T23:44:09.81483+08:00
startTime=2021-07-09T23:44:09.814784+08:00
elapsedNano=46065
timezone=CST
ids={"eventId":"67d64dab-f3ea-4b77-93d0-6782caf4cfee"}
app={"appName":"rk-demo","appVersion":"master-f414049","entryName":"greeter","entryType":"GrpcEntry"}
env={"arch":"amd64","az":"*","domain":"*","hostname":"lark.local","localIP":"10.8.0.2","os":"darwin","realm":"*","region":"*"}
payloads={"grpcMethod":"Healthy","grpcService":"rk.api.v1.RkCommonService","grpcType":"unaryServer","gwMethod":"","gwPath":"","gwScheme":"","gwUserAgent":""}
error={}
counters={}
pairs={"healthy":"true"}
timing={}
remoteAddr=localhost:58205
operation=/rk.api.v1.RkCommonService/Healthy
resCode=OK
eventStatus=Ended
EOE

Other interceptors

Please refer online docs

Development Status: Stable

Contributing

We encourage and support an active, healthy community of contributors — including you! Details are in the [contribution guide](CONTRIBUTING.md) and the [code of conduct](CODE_OF_CONDUCT.md). The rk maintainers keep an eye on issues and pull requests, but you can also report any negative conduct to [email protected].

Released under the [Apache 2.0 License](LICENSE).


*Note that all licence references and agreements mentioned in the rk-boot README section above are relevant to that project's source code only.