lug

package module
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2021 License: Apache-2.0 Imports: 24 Imported by: 0

README

lug

  1. protoc curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v3.7.1/protoc-3.7.1-linux-x86_64.zip go get github.com/golang/protobuf/protoc-gen-go@v1.3.2 go install -v github.com/gogo/protobuf/protoc-gen-gofast go install -v github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger go install -v github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway go install -v github.com/vektra/mockery/cmd/mockery

  2. 配置管理

  3. golug是一个高度抽象和集成的微服务框架

  4. golug集成了config, log, command, plugin, grpc, http(fiber), task, broker等组件

  5. golug使用方便, 统一入口

  6. golug把http, grpc等server抽象成统一的entry, 统一使用习惯

  7. golug统一运行入口, 让多个服务同时集成和运行

  8. golug对grpc的protobuf进行定制处理, 让grpc server register更加方便

  9. golug 抽象plugin, 跟随config的动态化加载,

  10. golug config和watcher分离, config从本地文件加载, watcher可以从远程的任何的组件watch, 比如etcd

功能特性

  1. 健康检查, pprof
  2. 一切配置化, 通过plugin集成组建
  3. 集成log, metric, tracing
  4. 集成多种服务和server
  5. 一站式开发
  6. 环境自动检测, 本地项目生成
  7. 支持rest, grpc等

example

package http_entry

import (
	"fmt"

	"github.com/gofiber/fiber/v2"
	"github.com/pubgo/golug"
	"github.com/pubgo/golug/golug_entry"
	"github.com/pubgo/xerror"
)

func GetEntry() golug_entry.Entry {
	ent := golug.NewHttpEntry("http")
	xerror.Panic(ent.Version("v0.0.1"))
	xerror.Panic(ent.Description("entry http test"))

	ent.Use(func(ctx *fiber.Ctx) error {
		fmt.Println("ok")

		return ctx.Next()
	})

	ent.Group("/api", func(r fiber.Router) {
		r.Get("/", func(ctx *fiber.Ctx) error {
			_, err := ctx.WriteString("ok")
			return err
		})
	})

	return ent
}
import (
	"github.com/pubgo/golug"
	"github.com/pubgo/golug/example/ctl_entry"
	"github.com/pubgo/golug/example/grpc_entry"
	"github.com/pubgo/golug/example/http_entry"
	"github.com/pubgo/xerror"
)

func main() {
	xerror.Exit(golug.Init())
	xerror.Exit(golug.Run(
		http_entry.GetEntry(),
		ctl_entry.GetEntry(),
		grpc_entry.GetEntry(),
		grpc_entry.GetHttpEntry(),
	))
}

https://github.com/fullstorydev/grpcurl https://github.com/bojand/ghz https://github.com/bigwhite/expvarmon

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AfterStart

func AfterStart(fn func())

func AfterStop

func AfterStop(fn func())

func BeforeStart

func BeforeStart(fn func())

func BeforeStop

func BeforeStop(fn func())

func Debug added in v0.1.3

func Debug(fn func(mux *types.DebugMux))

func Entry added in v0.0.21

func Entry(fn func() entry.Entry) entry.Entry

func GetCfg

func GetCfg() config.Config

func NewCtl

func NewCtl(name string) ctl.Entry

func NewGrpc added in v0.0.21

func NewGrpc(name string) grpc.Entry

func NewRest

func NewRest(name string) rest.Entry

func NewTask

func NewTask(name string) task.Entry

func Plugin

func Plugin(plg plugin.Plugin, opts ...plugin.Opt)

func Run

func Run(short string, entries ...entry.Entry) error

func Start

func Start(ent entry.Entry) error

func Stop

func Stop(ent entry.Entry) error

Types

This section is empty.

Directories

Path Synopsis
builder
chi
kcp
db
ctl
proto/hello
Package hello is a reverse proxy.
Package hello is a reverse proxy.
proto/login
Package login is a reverse proxy.
Package login is a reverse proxy.
gid Module
internal
jwt
tls
pkg
attributes
Package attributes defines a generic key/value store used in various gRPC components.
Package attributes defines a generic key/value store used in various gRPC components.
chanx
Package buffer provides an implementation of an unbounded buffer.
Package buffer provides an implementation of an unbounded buffer.
env
k8s
shm
tls
plugins
Package registry is an interface for service discovery
Package registry is an interface for service discovery
etcdv3
Package etcdv3 provides an etcd version 3 registry
Package etcdv3 provides an etcd version 3 registry
gossip
Package gossip provides a gossip registry based on hashicorp/memberlist
Package gossip provides a gossip registry based on hashicorp/memberlist
k8s
mdns
Package mdns is a multicast dns registry
Package mdns is a multicast dns registry

Jump to

Keyboard shortcuts

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