trinitygo

package module
v0.1.38 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2021 License: MIT Imports: 42 Imported by: 0

README

trinitygo

Build Status Go Report Card GoDoc Release

golang restframework plugin with gin+gorm, fast and high scalable

Installation

$ go get github.com/PolarPanda611/trinitygo/trinitygo
$ trinitygo NewHttp [Your Project Name]
$ cd [Your Project Name] 
$ trinitygo NewCrud [Your Model Name]
$ swag init

// start your journey in Trinity
// you can check the demo under example folder 

Overview

  • Declarative router
  • IOC container & Dependency Injection
  • customize middleware
  • customize runtime (Tracing Analysis, user authentication , event bus ...)
  • support atomic request
  • support customize validator ( API permission , data validation ...)
  • support URL query analyze (search , filter , order by , preload ...)
  • integrate gorm
  • integrate gin

Getting Started

  • Trinity Guides wiki

Contributing

Feel free to create the Issue and PR . We need your help !

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultGRPC

func DefaultGRPC() application.Application

DefaultGRPC default grpc server

func DefaultHTTP

func DefaultHTTP(args ...bool) application.Application

DefaultHTTP default http server

func EnableHealthCheckURL added in v0.0.19

func EnableHealthCheckURL(path ...string)

EnableHealthCheckURL set config path

func New

func New(args ...bool) application.Application

New new application

func RegisterController added in v0.0.25

func RegisterController(controllerName string, instance interface{}, requestMaps ...*application.RequestMap)

RegisterController register service @controllerName basic request path of the controller @instance controller instance ,should be ptr @requestMaps optional ,register the request based on the basic path of controller

func RegisterInitSQL added in v0.1.22

func RegisterInitSQL(sql string)

RegisterInitSQL register init sql @instance should be ptr instance @defaultValues should be ptr instance default value will create the instance and will not update .

func RegisterInstance added in v0.0.25

func RegisterInstance(instance interface{}, tags ...string)

RegisterInstance register instance @instance instance of the class , should be ptr @tags the tags for the instance to specify

func RegisterModel added in v0.1.3

func RegisterModel(instance interface{}, defaultValues ...interface{})

RegisterModel register model @instance should be ptr instance @defaultValues should be ptr instance default value will create the instance and will not update .

func SetCasbinConfPath added in v0.0.35

func SetCasbinConfPath(path string)

SetCasbinConfPath set config path

func SetConfigPath

func SetConfigPath(path string)

SetConfigPath set config path

func SetFuncGetWhoAmI added in v0.0.35

func SetFuncGetWhoAmI(f func(app application.Application, c *gin.Context, db *gorm.DB) (interface{}, error))

SetFuncGetWhoAmI set _funcToGetWhoAmI

func SetHealthCheckDefaultHandler added in v0.0.19

func SetHealthCheckDefaultHandler(handler func(app application.Application) func(c *gin.Context))

SetHealthCheckDefaultHandler set default health check handler

func SetIsLogSelfCheck added in v0.0.22

func SetIsLogSelfCheck(isLog bool)

SetIsLogSelfCheck set is log self check by default , it is true

func SetKeyword added in v0.0.37

func SetKeyword(k keyword.Keyword)

SetKeyword set keywork list

func SetResponseFactory added in v0.0.37

func SetResponseFactory(f func(status int, res interface{}, runtime map[string]string) interface{})

SetResponseFactory set response factory

Types

type Application

type Application struct {
	// contains filtered or unexported fields
}

Application core of trinity

func (*Application) Conf

func (app *Application) Conf() conf.Conf

Conf get conf

func (*Application) ContextPool

func (app *Application) ContextPool() *application.ContextPool

ContextPool get contextpoo;

func (*Application) ControllerPool

func (app *Application) ControllerPool() *application.ControllerPool

ControllerPool get all service pool

func (*Application) DB

func (app *Application) DB() *gorm.DB

DB get db

func (*Application) Enforcer added in v0.0.35

func (app *Application) Enforcer() *casbin.Enforcer

Enforcer get casbin enforcer instance

func (*Application) GetGRPCServer

func (app *Application) GetGRPCServer() *grpc.Server

GetGRPCServer get grpc server instance

func (*Application) InitGRPC

func (app *Application) InitGRPC()

InitGRPC serve grpc

func (*Application) InitHTTP

func (app *Application) InitHTTP()

InitHTTP serve http

func (*Application) InitRouter

func (app *Application) InitRouter()

InitRouter init router use gin framework by default

func (*Application) InitTrinity

func (app *Application) InitTrinity()

InitTrinity serve grpc

func (*Application) InstallDB

func (app *Application) InstallDB(f func() *gorm.DB)

InstallDB install db

func (*Application) InstancePool added in v0.0.25

func (app *Application) InstancePool() *application.InstancePool

InstancePool get all service pool

func (*Application) IsLogSelfCheck added in v0.0.22

func (app *Application) IsLogSelfCheck() bool

IsLogSelfCheck if log self check

func (*Application) Keyword added in v0.0.37

func (app *Application) Keyword() keyword.Keyword

Keyword get key word list

func (*Application) Logger

func (app *Application) Logger() *golog.Logger

Logger get logger

func (*Application) RegRuntimeKey

func (app *Application) RegRuntimeKey(runtime ...truntime.RuntimeKey) application.Application

RegRuntimeKey register runtime key the runtime key should be lower case , because when the metadata transfer , it will all transform to lower case

func (*Application) ResponseFactory added in v0.0.37

func (app *Application) ResponseFactory() func(status int, res interface{}, runtime map[string]string) interface{}

ResponseFactory get response factory

func (*Application) Router

func (app *Application) Router() *gin.Engine

Router get router

func (*Application) RuntimeKeys

func (app *Application) RuntimeKeys() []truntime.RuntimeKey

RuntimeKeys get runtime keys

func (*Application) ServeGRPC

func (app *Application) ServeGRPC()

ServeGRPC serve grpc server

func (*Application) ServeHTTP

func (app *Application) ServeHTTP()

InitHTTP serve grpc

func (*Application) UseInterceptor

func (app *Application) UseInterceptor(interceptor ...grpc.UnaryServerInterceptor) application.Application

UseInterceptor application use interceptor, only impact on http server

func (*Application) UseMiddleware

func (app *Application) UseMiddleware(middleware ...gin.HandlerFunc) application.Application

UseMiddleware application use middleware , only impact on http server

Directories

Path Synopsis
* * @ Author: Daniel Tan * @ Date: 2020-04-07 09:41:11 * @ LastEditTime: 2020-07-29 19:03:26 * @ LastEditors: Daniel Tan * @ Description: * @ FilePath: /trinitygo/application/app.go * @ * @Author: Daniel TAN * @Description: * @Date: 2021-03-03 15:46:55 * @LastEditTime: 2021-03-17 01:47:28 * @LastEditors: Daniel TAN * @FilePath: /trinitygo/application/context_pool.go
* * @ Author: Daniel Tan * @ Date: 2020-04-07 09:41:11 * @ LastEditTime: 2020-07-29 19:03:26 * @ LastEditors: Daniel Tan * @ Description: * @ FilePath: /trinitygo/application/app.go * @ * @Author: Daniel TAN * @Description: * @Date: 2021-03-03 15:46:55 * @LastEditTime: 2021-03-17 01:47:28 * @LastEditors: Daniel TAN * @FilePath: /trinitygo/application/context_pool.go
example
* @Author: Daniel TAN * @Description: * @Date: 2020-09-01 09:15:45 * @LastEditTime: 2021-01-22 17:02:48 * @LastEditors: Daniel TAN * @FilePath: /trinitygo/httputil/httputil.go
* @Author: Daniel TAN * @Description: * @Date: 2020-09-01 09:15:45 * @LastEditTime: 2021-01-22 17:02:48 * @LastEditors: Daniel TAN * @FilePath: /trinitygo/httputil/httputil.go
interceptor
di
middleware
di
jwt
* @Author: Daniel TAN * @Description: * @Date: 2021-03-03 15:46:55 * @LastEditTime: 2021-06-28 19:22:28 * @LastEditors: Daniel TAN * @FilePath: /tcs/Users/01444547/IdeaProjects/trinitygo/testutil/util.go
* @Author: Daniel TAN * @Description: * @Date: 2021-03-03 15:46:55 * @LastEditTime: 2021-06-28 19:22:28 * @LastEditors: Daniel TAN * @FilePath: /tcs/Users/01444547/IdeaProjects/trinitygo/testutil/util.go
cmd
* @Author: Daniel TAN * @Description: * @Date: 2020-09-01 09:15:45 * @LastEditTime: 2021-03-17 01:48:00 * @LastEditors: Daniel TAN * @FilePath: /trinitygo/trinitygo/cmd/version.go
* @Author: Daniel TAN * @Description: * @Date: 2020-09-01 09:15:45 * @LastEditTime: 2021-03-17 01:48:00 * @LastEditors: Daniel TAN * @FilePath: /trinitygo/trinitygo/cmd/version.go

Jump to

Keyboard shortcuts

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