module

package
v0.28.1 Latest Latest
Warning

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

Go to latest
Published: May 21, 2019 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package module 模块的管理

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Module

type Module struct {
	Tag
	Name        string
	Description string
	Deps        []string
	// contains filtered or unexported fields
}

Module 表示模块信息

func (*Module) AddAt added in v0.26.0

func (m *Module) AddAt(title string, f app.JobFunc, spec string, delay bool)

AddAt 添加新的定时任务

f 表示服务的运行函数; title 是对该服务的简要说明; spec 指定的时间点; delay 是否在任务执行完之后,才计算下一次的执行时间点。

func (*Module) AddCron added in v0.26.0

func (m *Module) AddCron(title string, f app.JobFunc, spec string, delay bool)

AddCron 添加新的定时任务

f 表示服务的运行函数; title 是对该服务的简要说明; spec cron 表达式,支持秒; delay 是否在任务执行完之后,才计算下一次的执行时间点。

func (*Module) AddService added in v0.25.0

func (m *Module) AddService(f app.ServiceFunc, title string)

AddService 添加新的服务

f 表示服务的运行函数; title 是对该服务的简要说明。

func (*Module) AddTicker added in v0.26.0

func (m *Module) AddTicker(title string, f app.JobFunc, dur time.Duration, delay bool)

AddTicker 添加新的定时任务

f 表示服务的运行函数; title 是对该服务的简要说明; delay 是否在任务执行完之后,才计算下一次的执行时间点。

func (*Module) Delete

func (m *Module) Delete(path string, h http.Handler) *mux.Prefix

Delete 指定个 Delete 请求处理

func (*Module) DeleteFunc

func (m *Module) DeleteFunc(path string, h func(w http.ResponseWriter, r *http.Request)) *mux.Prefix

DeleteFunc 指定一个 Delete 请求

func (*Module) Get

func (m *Module) Get(path string, h http.Handler) *mux.Prefix

Get 指定一个 GET 请求

func (*Module) GetFunc

func (m *Module) GetFunc(path string, h func(w http.ResponseWriter, r *http.Request)) *mux.Prefix

GetFunc 指定一个 GET 请求

func (*Module) Handle

func (m *Module) Handle(path string, h http.Handler, methods ...string) error

Handle 添加一个路由项

func (*Module) HandleFunc

func (m *Module) HandleFunc(path string, h func(w http.ResponseWriter, r *http.Request), methods ...string) error

HandleFunc 指定一个请求

func (*Module) NewTag added in v0.16.1

func (m *Module) NewTag(tag string) *Tag

NewTag 为当前模块生成特定名称的子模块。若已经存在,则直接返回该子模块。

Tag 是依赖关系与当前模块相同,但是功能完全独立的模块, 一般用于功能更新等操作。

func (*Module) Patch

func (m *Module) Patch(path string, h http.Handler) *mux.Prefix

Patch 指定个 Patch 请求处理

func (*Module) PatchFunc

func (m *Module) PatchFunc(path string, h func(w http.ResponseWriter, r *http.Request)) *mux.Prefix

PatchFunc 指定一个 Patch 请求

func (*Module) Plugin added in v0.25.0

func (m *Module) Plugin(name, description string, deps ...string)

Plugin 设置插件信息

在将模块设置为插件模式时,可以在插件的初始化函数中,采用此方法设置插件的基本信息。

func (*Module) Post

func (m *Module) Post(path string, h http.Handler) *mux.Prefix

Post 指定个 POST 请求处理

func (*Module) PostFunc

func (m *Module) PostFunc(path string, h func(w http.ResponseWriter, r *http.Request)) *mux.Prefix

PostFunc 指定一个 Post 请求

func (*Module) Prefix

func (m *Module) Prefix(prefix string) *mux.Prefix

Prefix 声明一个 Prefix 实例。

func (*Module) Put

func (m *Module) Put(path string, h http.Handler) *mux.Prefix

Put 指定个 Put 请求处理

func (*Module) PutFunc

func (m *Module) PutFunc(path string, h func(w http.ResponseWriter, r *http.Request)) *mux.Prefix

PutFunc 指定一个 Put 请求

type Modules added in v0.25.0

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

Modules 模块管理

func NewModules added in v0.25.0

func NewModules(app *app.App, plugin string) (*Modules, error)

NewModules 声明新的 Modules 对象

func (*Modules) Init added in v0.25.0

func (ms *Modules) Init(tag string, info *log.Logger) error

Init 初始化所有的模块或是模块下指定标签名称的函数。

若指定了 tag 参数,则只初始化该名称的子模块内容。

func (*Modules) Modules added in v0.25.0

func (ms *Modules) Modules() []*Module

Modules 当前系统使用的所有模块信息

func (*Modules) NewModule added in v0.25.0

func (ms *Modules) NewModule(name, desc string, deps ...string) *Module

NewModule 声明一个新的模块

name 模块名称,需要全局唯一; desc 模块的详细信息; deps 表示当前模块的依赖模块名称,可以是插件中的模块名称。

func (*Modules) Tags added in v0.25.0

func (ms *Modules) Tags() []string

Tags 返回所有的子模块名称

type Tag added in v0.26.0

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

Tag 表示与特写标签相关联的初始化函数列表。 依附地模块,共享模块的依赖关系。

一般是各个模块下的安装脚本使用。

func (*Tag) AddInit added in v0.26.0

func (t *Tag) AddInit(f func() error, title string) *Tag

AddInit 添加一个初始化函数

title 该初始化函数的名称。没有则会自动生成一个序号,多个,则取第一个元素。

Jump to

Keyboard shortcuts

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