stark

package module
v0.0.0-...-744775d Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2024 License: MIT Imports: 10 Imported by: 0

README

stark

A lightweight framework base on Gin

工具链

  • 日志
  • 监控告警
  • 链路追踪
  • 异步任务
  • 消息队列

Documentation

Index

Constants

View Source
const (
	VERSION = "v0.0.1"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Application

type Application struct {
	Name       string
	Host       string
	Port       int64
	Config     *config.Config
	LoadConfig func() error
	SetupVars  func() error
	// RegisterModule   func() error
	RegisterCallback map[CallbackPosition]CallbackFunc
}

type CallbackFunc

type CallbackFunc func() error

type CallbackPosition

type CallbackPosition int
const (
	// 在 InitGlobalConfig 后调用
	POSITION_GLOBAL_CONFIG CallbackPosition = iota + 1
	// 在 InitGlobalLogger 后调用
	POSITION_INIT_LOGGER
	// 在 Module Register 后调用
	POSITION_MODULE_REGISTER
	// 调用 LoadConfig 方法后
	POSITION_LOAD_CONFIG
	// 调用 SetupVars 方法后
	POSITION_SETUP_VARS
	// 调用 New 方法后
	POSITION_NEW
)

type DatabaseIface

type DatabaseIface interface {
	Get(ctx context.Context) *gorm.DB
}
var Database DatabaseIface

type GinApplication

type GinApplication struct {
	Application                 *Application
	TracerLogger                *logrus.Logger
	RegisterHttpRoute           func(*gin.Engine) error
	RegisterGracefulStopHandler func(sig ...os.Signal) error
}

type LoggerIface

type LoggerIface interface {

	// 普通日志
	Info(ctx context.Context, args ...interface{})
	Infof(ctx context.Context, format string, args ...interface{})

	// 警告日志
	Warn(ctx context.Context, args ...interface{})
	Warnf(ctx context.Context, format string, args ...interface{})

	// 错误日志
	Error(ctx context.Context, args ...interface{})
	Errorf(ctx context.Context, format string, args ...interface{})
}
var Logger LoggerIface

type RedisConn

type RedisConn interface {
	Get(ctx context.Context) *redis.Client
}
var Redis RedisConn

Directories

Path Synopsis
examples
app
internal
pkg

Jump to

Keyboard shortcuts

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