define

package
v0.2.95 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2024 License: LGPL-2.1 Imports: 8 Imported by: 38

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 ComponentDefinition added in v0.2.58

type ComponentDefinition struct {
	Name          string // 组件名称
	InterfaceName string // 组件接口名称
}

ComponentDefinition 组件定义

func Component

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

Component 定义组件

func ComponentWithInterface added in v0.2.58

func ComponentWithInterface[COMP, COMP_IFACE any](compLib ...pt.ComponentLib) ComponentDefinition

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

type ComponentInterfaceDefinition added in v0.2.58

type ComponentInterfaceDefinition struct {
	Name    string                                         // 组件接口名称
	Declare generic.PairFunc1[any, pt.ComponentPT, string] // 声明组件原型
}

ComponentInterfaceDefinition 组件接口定义

func ComponentInterface

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

ComponentInterface 定义组件接口

type PluginDefinition added in v0.2.58

type PluginDefinition[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] // 使用插件
}

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

func Plugin

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

Plugin 定义通用插件

type PluginInterfaceDefinition added in v0.2.58

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

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

func PluginInterface

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

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

type RuntimePluginDefinition added in v0.2.58

type RuntimePluginDefinition[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]      // 使用插件
}

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

func RuntimePlugin

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

RuntimePlugin 定义运行时插件

type RuntimePluginInterfaceDefinition added in v0.2.58

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

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

func RuntimePluginInterface

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

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

type ServicePluginDefinition added in v0.2.58

type ServicePluginDefinition[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]      // 使用插件
}

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

func ServicePlugin

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

ServicePlugin 定义服务插件

type ServicePluginInterfaceDefinition added in v0.2.58

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

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

func ServicePluginInterface

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

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

Jump to

Keyboard shortcuts

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