GitHub

您所在的位置:网站首页 gofast官网加速器 GitHub

GitHub

2024-07-13 16:57| 来源: 网络整理| 查看: 265

[Preview] 当前持续完善中,不可生产中使用 [Preview] GoFast Micro-Service Framework

GoFast是一个用Go语言实现的微服务开发框架。他的产生源于目前流行的gin、go-zero、fastify等众多开源框架;同时结合了作者多年的开发实践经验,很多模块的实现方式都是作者首创;当然也免不了不断借鉴社区中优秀的设计理念。我们的目标是简洁高效易上手,在封装大量特性的同时又不失灵活性。希望你能喜欢GoFast。

更多了解:GoFast的实现细节

GoFast的微服务:虽然也提供现成的微服务治理能力,但我们想强调的是,GoFast更专注于帮助框架使用者清晰的开发业务逻辑。大型项目上框架应该弱化微服务治理,将这一部分特性交给istio处理。

Installation

To install GoFast package, you need to install Go and set your Go workspace first.

The first need Go installed (version 1.15+ is required), then you can use the below Go command to install GoFast.

$ go get -u github.com/qinchende/gofast Quick start # assume the following codes in example.go file $ cat example.go main.glob..func1.1 (1 handlers) [GoFast-debug] GET /admin/chende --> main.glob..func2.1 (1 handlers) [GoFast-debug] GET /admin2/zht --> main.glob..func1.1 (1 handlers) [GoFast-debug] GET /admin2/group2/lmx --> main.glob..func1.1 (1 handlers) ++++++++++The route tree: (GET) └── /admin [false-/2] ├── /chende [true-] └── 2/ [false-zg] ├── zht [true-] └── group2/lmx [true-] (POST) └── /root [true-] ++++++++++THE END. 2021/02/20 02:56:00 App OnReady Call. 2021/02/20 02:56:00 Listening and serving HTTP on 127.0.0.1:8099">[GoFast-debug] POST /root --> main.glob..func1.1 (1 handlers) [GoFast-debug] GET /admin/chende --> main.glob..func2.1 (1 handlers) [GoFast-debug] GET /admin2/zht --> main.glob..func1.1 (1 handlers) [GoFast-debug] GET /admin2/group2/lmx --> main.glob..func1.1 (1 handlers) ++++++++++The route tree: (GET) └── /admin [false-/2] ├── /chende [true-] └── 2/ [false-zg] ├── zht [true-] └── group2/lmx [true-] (POST) └── /root [true-] ++++++++++THE END. 2021/02/20 02:56:00 App OnReady Call. 2021/02/20 02:56:00 Listening and serving HTTP on 127.0.0.1:8099

浏览器输入网址访问地址:127.0.0.1:8099/admin/chende,日志会输出:

2021/02/20 02:57:17 app fit before 1 2021/02/20 02:57:20 before root 2021/02/20 02:57:20 before group admin 2021/02/20 02:57:20 before tst_url 2021/02/20 02:57:20 handle chende 2021/02/20 02:57:20 preSend tst_url 2021/02/20 02:57:20 afterSend tst_url 2021/02/20 02:57:20 after tst_url 2021/02/20 02:57:20 after group admin 2021/02/20 02:57:20 after root 2021/02/20 02:57:20 app fit after 1 The request cost 3000ms [GET] /admin/chende (127.0.0.1/02-20 02:57:20) 200/24 [3000] B: C: P: R: E: Core feature Like gin feature

GoFast目前复用了Gin的很多特性,除特别说明之外,使用方式一样。

Server Handlers

应用启动之后,在开始监听端口之后调用OnReady事件,应用关闭退出之前调用OnClose事件

app.OnReady(func(fast *fst.GoFast) { log.Println("App OnReady Call.") log.Printf("Listening and serving HTTP on %s\n", "127.0.0.1:8099") }) app.OnClose(func(fast *fst.GoFast) { log.Println("App OnClose Call.") }) Router Handlers

分组或路由项事件是一样的,现在支持下面四个,以后慢慢扩展和调整

tst.Before(handler("before tst_url")) tst.After(handler("after tst_url")) tst.PreSend(handler("preSend tst_url")) tst.AfterSend(handler("afterSend tst_url")) benchmark License

This project is licensed under the terms of the MIT license.

(其它介绍陆续补充...)



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3