golug

package module
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

README

golug

  1. golug是一个高度抽象和集成的微服务框架
  2. golug集成了config, log, command, plugin, grpc, http(fiber), task, broker等组件
  3. golug使用方便, 统一入口
  4. golug把http, grpc等server抽象成统一的entry, 统一使用习惯
  5. golug统一运行入口, 让多个服务同时集成和运行
  6. golug对grpc的protobuf进行定制处理, 让grpc server register更加方便
  7. golug 抽象plugin, 跟随config的动态化加载,
  8. golug config和watcher分离, config从本地文件加载, watcher可以从远程的任何的组件watch, 比如etcd

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(),
	))
}

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 NewCtl added in v0.0.9

func NewCtl(name string) golug_ctl.Entry

func NewGrpc added in v0.0.9

func NewGrpc(name string) golug_grpc.Entry

func NewRest added in v0.0.9

func NewRest(name string) golug_rest.Entry

func NewTask added in v0.0.9

func NewTask(name string) golug_task.Entry

func RegisterPlugin

func RegisterPlugin(plugin golug_plugin.Plugin, opts ...golug_plugin.ManagerOption)

func Run

func Run(entries ...golug_entry.Entry)

Types

This section is empty.

Directories

Path Synopsis
client
cmds
golug command
golug/grpcurl
Command grpcurl makes gRPC requests (a la cURL, but HTTP/2).
Command grpcurl makes gRPC requests (a la cURL, but HTTP/2).
Package errors provides a way to return detailed information for an RPC request error.
Package errors provides a way to return detailed information for an RPC request error.
Package registry is an interface for service discovery
Package registry is an interface for service discovery
internal
pkg
golug_k8s/client
Package client provides an implementation of a restricted subset of kubernetes API client
Package client provides an implementation of a restricted subset of kubernetes API client

Jump to

Keyboard shortcuts

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