define

package
v0.2.28 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2024 License: LGPL-2.1 Imports: 8 Imported by: 44

Documentation

Overview

Package define 利用泛型特性,简化代码编写。

  • 支持组件与组件接口定义,可以参考官方样例:https://git.golaxy.org/examples,学习如何使用。
  • 支持插件与插件接口定义,注意插件共有运行时插件、服务插件、通用插件三种,可以参考官方样例:https://git.golaxy.org/examples,学习如何使用。
  • 使用Goland作为IDE时,需要更新至2023.2版本以上,否则可能会有误报错。
  • 根据代码结构,选择性使用。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Component

type Component struct {
	Name           string // 组件名称
	Implementation string // 组件实现名称
}

Component 组件

func DefineComponent

func DefineComponent[COMP any](compLib pt.ComponentLib) Component

DefineComponent 定义组件

func DefineComponentWithInterface

func DefineComponentWithInterface[COMP, COMP_IFACE any](compLib pt.ComponentLib) Component

DefineComponentWithInterface 定义有接口的组件,接口名称将作为组件名

type ComponentInterface

type ComponentInterface struct {
	Name     string                             // 组件接口名称
	Register generic.Func1[any, pt.ComponentPT] // 注册组件原型
}

ComponentInterface 组件接口

func DefineComponentInterface

func DefineComponentInterface[COMP_IFACE any](compLib pt.ComponentLib) ComponentInterface

DefineComponentInterface 定义组件接口

type Plugin

type Plugin[PLUGIN_IFACE, OPTION any] struct {
	Name      string                                             // 插件名称
	Install   generic.ActionVar1[plugin.PluginProvider, OPTION]  // 向插件包安装
	Uninstall generic.Action1[plugin.PluginProvider]             // 从插件包卸载
	Using     generic.Func1[plugin.PluginProvider, PLUGIN_IFACE] // 使用插件
}

Plugin 通用插件,在运行时上下文和服务上下文中,均可安装与使用

func DefinePlugin

func DefinePlugin[PLUGIN_IFACE, OPTION any](creator generic.FuncVar0[OPTION, PLUGIN_IFACE]) Plugin[PLUGIN_IFACE, OPTION]

DefinePlugin 定义通用插件

type PluginInterface

type PluginInterface[PLUGIN_IFACE any] struct {
	Name  string                                             // 插件名称
	Using generic.Func1[plugin.PluginProvider, PLUGIN_IFACE] // 使用插件
}

PluginInterface 通用插件接口,在运行时上下文和服务上下文中,均可使用

func DefinePluginInterface

func DefinePluginInterface[PLUGIN_IFACE any]() PluginInterface[PLUGIN_IFACE]

DefinePluginInterface 定义通用插件接口,因为仅有接口没有实现,所以不能用于向插件包安装插件

type RuntimePlugin

type RuntimePlugin[PLUGIN_IFACE, OPTION any] struct {
	Name      string                                            // 插件名称
	Install   generic.ActionVar1[plugin.PluginProvider, OPTION] // 向插件包安装
	Uninstall generic.Action1[plugin.PluginProvider]            // 从插件包卸载
	Using     generic.Func1[runtime.Context, PLUGIN_IFACE]      // 使用插件
}

RuntimePlugin 运行时插件,只能在运行时上下文中安装与使用

func DefineRuntimePlugin

func DefineRuntimePlugin[PLUGIN_IFACE, OPTION any](creator generic.FuncVar0[OPTION, PLUGIN_IFACE]) RuntimePlugin[PLUGIN_IFACE, OPTION]

DefineRuntimePlugin 定义运行时插件

type RuntimePluginInterface

type RuntimePluginInterface[PLUGIN_IFACE any] struct {
	Name  string                                       // 插件名称
	Using generic.Func1[runtime.Context, PLUGIN_IFACE] // 使用插件
}

RuntimePluginInterface 运行时插件接口,只能在运行时上下文中使用

func DefineRuntimePluginInterface

func DefineRuntimePluginInterface[PLUGIN_IFACE any]() RuntimePluginInterface[PLUGIN_IFACE]

DefineRuntimePluginInterface 定义运行时插件接口,因为仅有接口没有实现,所以不能用于向插件包安装插件

type ServicePlugin

type ServicePlugin[PLUGIN_IFACE, OPTION any] struct {
	Name      string                                            // 插件名称
	Install   generic.ActionVar1[plugin.PluginProvider, OPTION] // 向插件包安装
	Uninstall generic.Action1[plugin.PluginProvider]            // 从插件包卸载
	Using     generic.Func1[service.Context, PLUGIN_IFACE]      // 使用插件
}

ServicePlugin 服务插件,只能在服务上下文中安装与使用

func DefineServicePlugin

func DefineServicePlugin[PLUGIN_IFACE, OPTION any](creator generic.FuncVar0[OPTION, PLUGIN_IFACE]) ServicePlugin[PLUGIN_IFACE, OPTION]

DefineServicePlugin 定义服务插件

type ServicePluginInterface

type ServicePluginInterface[PLUGIN_IFACE any] struct {
	Name  string                                       // 插件名称
	Using generic.Func1[service.Context, PLUGIN_IFACE] // 使用插件
}

ServicePluginInterface 服务插件接口,只能在服务上下文中使用

func DefineServicePluginInterface

func DefineServicePluginInterface[PLUGIN_IFACE any]() ServicePluginInterface[PLUGIN_IFACE]

DefineServicePluginInterface 定义服务插件接口,因为仅有接口没有实现,所以不能用于向插件包安装插件

Jump to

Keyboard shortcuts

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