core

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Gconfig config.Config

Functions

func AddJob

func AddJob() (string, error)

func CreatePidFile

func CreatePidFile(path string) error

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 NewLogrusHandler

func NewLogrusHandler(l *logrus.Logger) slog.Handler

func RemovePidFile

func RemovePidFile(path string)

func ServerMQTT

func ServerMQTT(mqttLogger *logrus.Logger) (*mqtt.Server, error)

func StartCron

func StartCron()

Types

type Cycle

type Cycle struct {
	Conf         *config.Config
	DB           *gorm.DB
	Logger       logrus.FieldLogger
	MQTT         *mqtt.Server
	Mgr          *InstanceManager
	AccessLogger *logrus.Logger
	WG           *sync.WaitGroup
}

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

type LogrusHandler

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

func (*LogrusHandler) Enabled

func (h *LogrusHandler) Enabled(ctx context.Context, lvl slog.Level) bool

func (*LogrusHandler) Handle

func (h *LogrusHandler) Handle(ctx context.Context, r slog.Record) error

func (*LogrusHandler) WithAttrs

func (h *LogrusHandler) WithAttrs(attrs []slog.Attr) slog.Handler

func (*LogrusHandler) WithGroup

func (h *LogrusHandler) WithGroup(name string) slog.Handler

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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