Skip to content

release: engine events, Lua subscribe, ConsoleCommands and shutdown lifetime#57

Merged
tgiachi merged 14 commits into
mainfrom
develop
Jul 3, 2026
Merged

release: engine events, Lua subscribe, ConsoleCommands and shutdown lifetime#57
tgiachi merged 14 commits into
mainfrom
develop

Conversation

@tgiachi

@tgiachi tgiachi commented Jul 3, 2026

Copy link
Copy Markdown
Owner

Release

Promotes develop to main. Expected version: 0.20.0 (all feat/fix/refactor, no breaking markers).

Included

  • feat(bootstrap): engine lifecycle events on the event bus (EngineStartingEvent/EngineStartedEvent/EngineStoppedEvent, guarded, empty bootstrap unaffected).
  • feat(lua): events.subscribe("engine_started", fn) - catch-all bus forwarder with snake_case event names and payload keys, serialized closure invocation, RegisterLuaEvents().
  • feat(consolecommands): NEW package SquidStd.ConsoleCommands - interactive prompt (locked mode, TAB autocomplete, history, logs above the prompt via the container sink hook), command registry with aliases and quoted args, builtins help/clear/exit, [RegisterConsoleCommand] + source generator, sample and docs.
  • feat(bootstrap): ISquidStdLifetime shared shutdown signal - RequestShutdown() ends RunAsync, graceful Ctrl+C, ConsoleCommands exit terminates a RunAsync host cleanly.
  • feat(templates): host template with config hooks and engine event subscriptions.

Full suite 1064/1064; docfx 0 warnings.

tgiachi added 14 commits July 3, 2026 15:02
…case event names

Adds LuaEventBusForwarder (subscribes to the IEvent catch-all channel and
forwards every event to the Lua bridge as snake_case names with snake_case
payload keys), the events.subscribe function alongside events.on, a
RegisterLuaEvents() registration helper, and serialized closure invocation
in the bridge (bus events arrive on arbitrary threads).
…scriptions

Also demos events.subscribe in the ScriptingLua sample and documents the
snake_case event naming convention.
feat: engine lifecycle events on the bus with Lua events.subscribe
- feat(generators): ConsoleCommandRegistrationGenerator emitting RegisterGeneratedConsoleCommands with singleton registration and deferred RegisterCommand wiring via DryIoc RegisterInitializer
- feat(generators): SQDGEN006 diagnostic for unsupported console command classes
- feat(samples): SquidStd.Samples.ConsoleCommands with attribute, delegate and builtin command usage
- test(generators): ConsoleCommandRegistrationGeneratorTests covering generation, description fallback, no-op and diagnostics
- docs: SquidStd.ConsoleCommands package README, docfx article and toc entry
…ries on redefine, single log stream in the sample
feat: SquidStd.ConsoleCommands - interactive console commands with a fixed prompt
feat(bootstrap): shared shutdown lifetime (ISquidStdLifetime)

Assert.Equal("MyApp:5:true", script.Globals.Get("captured").String);

forwarder.Dispose();

Assert.Equal(200, (int)script.Globals.Get("counter").Number);

forwarder.Dispose();
Comment on lines +56 to +73
foreach (var alias in aliases)
{
if (!_commands.TryAdd(alias, entry))
{
_logger.Warning("Console command '{Command}' redefined", alias);
var displaced = _commands[alias];
_commands[alias] = entry;

// Keep help output truthful: drop every other key that still points at the
// displaced entry, so its stale alias list is no longer reported.
foreach (var staleKey in _commands.Where(pair => ReferenceEquals(pair.Value, displaced))
.Select(pair => pair.Key)
.ToArray())
{
_commands.TryRemove(staleKey, out _);
}
}
}
Comment on lines +161 to +165
catch (Exception ex)
{
_logger.Error(ex, "Console command '{Command}' failed", name);
writeLine($"Command '{name}' failed: {ex.Message}");
}
Comment on lines +87 to +91
catch (Exception ex)
{
Log.ForContext<LuaEventBusForwarder>()
.Warning(ex, "Failed to forward event {EventType} to Lua", eventData.GetType().Name);
}
{
private readonly List<(Type ConfigType, Action<object> Apply)> _configHooks = [];
private readonly List<Action<IConfigManagerService>> _configReadyCallbacks = [];
private readonly SquidStdLifetimeService _lifetime = new();
Comment on lines +217 to +218
catch (OperationCanceledException) when (cancellationToken.IsCancellationRequested
|| _lifetime.ShutdownToken.IsCancellationRequested) { }
Comment on lines +357 to +360
catch (Exception ex)
{
logger.Warning(ex, "EngineStoppedEvent publish failed");
}
@tgiachi
tgiachi merged commit b00a3a9 into main Jul 3, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants