Documentation
¶
Index ¶
- Variables
- func AddJob() (string, error)
- func CreatePidFile(path string) error
- func NewLogrusHandler(l *logrus.Logger) slog.Handler
- func RemovePidFile(path string)
- func ServerMQTT(mqttLogger *logrus.Logger) (*mqtt.Server, error)
- func StartCron()
- type Cycle
- type InstanceManager
- func (m *InstanceManager) Create(typ, id string, cfg pluginapi.InstanceConfig) (pluginapi.Instance, error)
- func (m *InstanceManager) CreateWithContext(parentCtx context.Context, typ, id string, cfg pluginapi.InstanceConfig) (pluginapi.Instance, error)
- func (m *InstanceManager) Destroy(typ, id string) error
- func (m *InstanceManager) DestroyAll()
- func (m *InstanceManager) Get(typ, id string) (pluginapi.Instance, bool)
- func (m *InstanceManager) Update(typ, id string, cfg pluginapi.InstanceConfig) error
- type LogrusHandler
Constants ¶
This section is empty.
Variables ¶
var Gconfig config.Config
Functions ¶
func CreatePidFile ¶
createPidFile checks whether a process recorded in pid file exists. If exists -> return error. If not exists (or stale pid file) -> write current pid to the file.
Notes:
- On Unix, it uses kill(pid, 0) to probe existence/permission.
- On Windows, syscall-based probing isn't provided here; it falls back to "best effort": if pid file exists and is non-empty, it returns an error to avoid double-run. (You can implement Windows-specific process checks if needed.)
func RemovePidFile ¶
func RemovePidFile(path string)
Types ¶
type InstanceManager ¶
type InstanceManager struct {
// contains filtered or unexported fields
}
InstanceManager 管理进程中所有插件实例 InstanceManager manages all plugin instances in the process.
func NewInstanceManager ¶
func NewInstanceManager(rootCtx context.Context, env *pluginapi.HostEnv) *InstanceManager
NewInstanceManager 创建新的实例管理器,如果 rootCtx 为 nil 则使用 context.Background() NewInstanceManager creates a new instance manager; if rootCtx is nil, uses context.Background().
func (*InstanceManager) Create ¶
func (m *InstanceManager) Create( typ, id string, cfg pluginapi.InstanceConfig, ) (pluginapi.Instance, error)
Create 兼容简化接口:默认使用 rootCtx Create is a convenience wrapper using rootCtx.
func (*InstanceManager) CreateWithContext ¶
func (m *InstanceManager) CreateWithContext( parentCtx context.Context, typ, id string, cfg pluginapi.InstanceConfig, ) (pluginapi.Instance, error)
CreateWithContext 使用指定 parentCtx 创建实例;parentCtx 为 nil 则使用 rootCtx CreateWithContext uses parentCtx; if parentCtx is nil, uses rootCtx.
func (*InstanceManager) Destroy ¶
func (m *InstanceManager) Destroy(typ, id string) error
Destroy 销毁单个实例(调用 Close 并从管理器中删除) Destroy destroys a single instance (calls Close and removes it).
func (*InstanceManager) DestroyAll ¶
func (m *InstanceManager) DestroyAll()
DestroyAll 销毁所有实例,适合在进程退出时调用 DestroyAll destroys all instances, suitable for process shutdown.
func (*InstanceManager) Get ¶
func (m *InstanceManager) Get(typ, id string) (pluginapi.Instance, bool)
Get 获取某个实例 Get returns an instance by type and ID.
func (*InstanceManager) Update ¶
func (m *InstanceManager) Update( typ, id string, cfg pluginapi.InstanceConfig, ) error