github.com/zly-app/zapp@v1.3.3/core/app.go (about)

     1  /*
     2  -------------------------------------------------
     3     Author :       zlyuancn
     4     date:         2020/7/2
     5     Description :
     6  -------------------------------------------------
     7  */
     8  
     9  package core
    10  
    11  import (
    12  	"context"
    13  )
    14  
    15  // app
    16  //
    17  // 用于将所有模块连起来
    18  type IApp interface {
    19  	// app名
    20  	Name() string
    21  	// 启动
    22  	//
    23  	// 开启所有服务并挂起
    24  	Run()
    25  	// 退出
    26  	//
    27  	// 结束所有服务并退出
    28  	Exit()
    29  	// 基础上下文, 这个用于监听服务结束, app会在关闭服务之前调用cancel()
    30  	BaseContext() context.Context
    31  
    32  	// 获取配置
    33  	GetConfig() IConfig
    34  
    35  	// 日志组件
    36  	ILogger
    37  	// 获取日志组件
    38  	GetLogger() ILogger
    39  
    40  	// 获取组件
    41  	GetComponent() IComponent
    42  
    43  	// 获取插件
    44  	GetPlugin(pluginType PluginType) (IPlugin, bool)
    45  	// 注入插件
    46  	InjectPlugin(pluginType PluginType, a ...interface{})
    47  
    48  	// 获取服务
    49  	GetService(serviceType ServiceType) (IService, bool)
    50  	// 注入服务
    51  	InjectService(serviceType ServiceType, a ...interface{})
    52  }