service

package
v1.3.3 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2024 License: MIT Imports: 44 Imported by: 0

Documentation

Overview

Package service Date: 2024/3/6 11:07 Author: Amu Description:

Package service Date: 2024/3/27 16:06 Author: Amu Description:

Package service Date: 2024/3/6 11:08 Author: Amu Description:

Package service Date: 2024/3/6 11:08 Author: Amu Description:

Package service Date: 2024/3/6 11:08 Author: Amu Description:

Package service Date: 2024/03/19 17:33:57 Author: Amu Description:

Package service Date: 2024/3/27 17:04 Author: Amu Description:

Package service Date: 2024/3/6 11:09 Author: Amu Description:

Package service Date: 2024/3/6 11:00 Author: Amu Description:

Package service Date: 2024/3/6 13:34 Author: Amu Description:

Package service Date: 2024/3/11 10:38 Author: Amu Description:

Index

Constants

View Source
const (
	LatestDiskReadKey   = "latest_disk_io_read_"
	LatestDisKWriteKey  = "latest_disk_io_write_"
	LatestNetReceiveKey = "latest_net_io_receive_"
	LatestNetSendKey    = "latest_net_io_send_"
)

Variables

View Source
var InjectorSet = wire.NewSet(NewInjector)
View Source
var PrepareSet = wire.NewSet(wire.Struct(new(Prepare), "*"))

Functions

func Init

func Init(ctx context.Context, opts ...Option) (func(), error)

func InitAuth

func InitAuth(config *Config, authStore *jwtauth.Store, db *database.DB) (auth.Auther, func(), error)

func InitAuthStore

func InitAuthStore(config *Config) (*jwtauth.Store, func(), error)

func InitHttpServer

func InitHttpServer(ctx context.Context, config *Config, app *fiber.App) func()

func NewDB

func NewDB(config *Config, models *model.Models) (*database.DB, error)

func NewFiberApp

func NewFiberApp(config *Config, r IRouter) *fiber.App

func NewLogger

func NewLogger(config *Config) *logger.Logger

func Run

func Run(ctx context.Context, opts ...Option) error

Types

type Auth

type Auth struct {
	Enable         bool
	SigningMethod  string
	SigningKey     string
	Expired        int
	RefreshExpired int
	Prefix         string
}

type Config

type Config struct {
	Fiber    Fiber
	Gorm     Gorm
	DB       DB
	Disk     Disk
	Task     Task
	Ethernet Ethernet
	Logger   Logger
	Auth     Auth
	InitData InitData
}

func NewConfig

func NewConfig(configFile string) (*Config, error)

NewConfig Load config file (toml/json/yaml)

type DB

type DB struct {
	Host     string
	Port     string
	User     string
	Password string
	DBName   string
	SSLMode  string
}

type Disk

type Disk struct {
	Devices []string
}

type Ethernet

type Ethernet struct {
	Names []string
}

type Fiber

type Fiber struct {
	Host            string
	Port            int
	ShutdownTimeout int
	SeverHeader     string
	AppName         string
	Prefork         bool
}

type Gorm

type Gorm struct {
	GenDoc            bool
	Debug             bool
	DBType            string
	MaxLifetime       int
	MaxOpenConns      int
	MaxIdleConns      int
	TablePrefix       string
	EnableAutoMigrate bool
}

type IRouter

type IRouter interface {
	Register(app *fiber.App) error
	Prefixes() []string
}

type InitData

type InitData struct {
	Enable         bool
	InitConfigFile string
}

type Injector

type Injector struct {
	App     *fiber.App
	Router  *Router
	Config  *Config
	Prepare *Prepare
	Logger  *logger.Logger
	Task    *TimedTask
}

func BuildInjector

func BuildInjector(configFile string) (*Injector, func(), error)

func NewInjector

func NewInjector(app *fiber.App, router *Router, prepare *Prepare, config *Config, task *TimedTask, logx *logger.Logger) (*Injector, error)

type Logger

type Logger struct {
	File         string
	Level        string
	RotationTime int
	MaxAge       int
}

type LoggerHandler

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

func NewLoggerHandler

func NewLoggerHandler() *LoggerHandler

func (*LoggerHandler) Handler

func (l *LoggerHandler) Handler(c *websocket.Conn)

type Option

type Option func(*options)

func SetConfigFile

func SetConfigFile(s string) Option

type Prepare

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

func (*Prepare) Init

func (a *Prepare) Init(config *Config)

type PrepareData

type PrepareData struct {
	Users Users `yaml:"users"`
}

type Router

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

func (*Router) Prefixes

func (a *Router) Prefixes() []string

func (*Router) Register

func (a *Router) Register(app *fiber.App) error

func (*Router) RegisterAPI

func (a *Router) RegisterAPI(app *fiber.App)

type Task

type Task struct {
	Interval int
}

type TimedTask

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

func NewTimedTask

func NewTimedTask(conf *Config, db *database.DB) *TimedTask

func (*TimedTask) Execute

func (a *TimedTask) Execute()

func (*TimedTask) Run

func (a *TimedTask) Run()

func (*TimedTask) Stop

func (a *TimedTask) Stop()

type User

type User struct {
	Username string `yaml:"username"`
	Password string `yaml:"password"`
	Remark   string `yaml:"remark"`
	IsAdmin  string `yaml:"is_admin"`
	Status   int    `yaml:"status"`
}

type Users

type Users []*User

Directories

Path Synopsis
Package audit Date: 2022/11/9 10:18 Author: Amu Description:
Package audit Date: 2022/11/9 10:18 Author: Amu Description:
api
Package api Date: 2022/11/9 10:18 Author: Amu Description:
Package api Date: 2022/11/9 10:18 Author: Amu Description:
repository
Package repository Date: 2022/11/9 10:18 Author: Amu Description:
Package repository Date: 2022/11/9 10:18 Author: Amu Description:
service
Package service Date: 2022/11/9 10:18 Author: Amu Description:
Package service Date: 2022/11/9 10:18 Author: Amu Description:
Package auth Date: 2024/3/27 16:38 Author: Amu Description:
Package auth Date: 2024/3/27 16:38 Author: Amu Description:
api
Package api Date: 2024/3/27 16:38 Author: Amu Description:
Package api Date: 2024/3/27 16:38 Author: Amu Description:
repository
Package repository Date: 2024/3/27 16:39 Author: Amu Description:
Package repository Date: 2024/3/27 16:39 Author: Amu Description:
service
Package service Date: 2024/3/27 16:39 Author: Amu Description:
Package service Date: 2024/3/27 16:39 Author: Amu Description:
Package container Date: 2024/3/6 12:44 Author: Amu Description:
Package container Date: 2024/3/6 12:44 Author: Amu Description:
api
Package api Date: 2024/3/6 12:44 Author: Amu Description:
Package api Date: 2024/3/6 12:44 Author: Amu Description:
repository
Package repository Date: 2024/3/6 12:46 Author: Amu Description:
Package repository Date: 2024/3/6 12:46 Author: Amu Description:
service
Package service Date: 2024/3/6 12:49 Author: Amu Description:
Package service Date: 2024/3/6 12:49 Author: Amu Description:
Package host Date: 2024/3/6 12:43 Author: Amu Description:
Package host Date: 2024/3/6 12:43 Author: Amu Description:
api
Package api Date: 2024/3/6 12:45 Author: Amu Description:
Package api Date: 2024/3/6 12:45 Author: Amu Description:
repository
Package repository Date: 2024/3/6 12:53 Author: Amu Description:
Package repository Date: 2024/3/6 12:53 Author: Amu Description:
service
Package service Date: 2024/3/6 12:53 Author: Amu Description:
Package service Date: 2024/3/6 12:53 Author: Amu Description:
Package middleware Date: 2024/3/27 16:20 Author: Amu Description:
Package middleware Date: 2024/3/27 16:20 Author: Amu Description:
Package model Date: 2022/11/9 10:18 Author: Amu Description:
Package model Date: 2022/11/9 10:18 Author: Amu Description:
Package schema Date: 2022/11/9 10:18 Author: Amu Description:
Package schema Date: 2022/11/9 10:18 Author: Amu Description:

Jump to

Keyboard shortcuts

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