diff --git a/eventbus/README.md b/eventbus/README.md index 47331a5..6f88065 100644 --- a/eventbus/README.md +++ b/eventbus/README.md @@ -1,37 +1,30 @@ # Wehlney EventBus Packages -This folder is a Unity Package Manager monorepo for the Wehlney EventBus stack. +This folder contains the EventBus packages in the `unity-packages` repository. ## Packages -- `com.wehlney.eventbus`: pure in-process EventBus core. No Reflex, no PurrNet, no project-specific dependencies. +- `com.wehlney.eventbus`: in-process EventBus core. No Reflex, no PurrNet, no project-specific dependencies. - `com.wehlney.eventbus.purrnet`: PurrNet runtime network-event sharing extension. Depends on `com.wehlney.eventbus` and PurrNet. - `com.wehlney.eventbus.reflex`: Reflex adapter registration helpers. Depends on `com.wehlney.eventbus`, `com.wehlney.eventbus.purrnet`, and Reflex. -## Install From Git +## Install from Git -After this folder is pushed to GitHub, install packages with `?path=` URLs: +Install packages with `?path=` URLs: ```json -"com.wehlney.eventbus": "https://github.com/wehlney/wehlney-unity-packages.git?path=/eventbus/com.wehlney.eventbus#v0.1.0", -"com.wehlney.eventbus.purrnet": "https://github.com/wehlney/wehlney-unity-packages.git?path=/eventbus/com.wehlney.eventbus.purrnet#v0.1.0", -"com.wehlney.eventbus.reflex": "https://github.com/wehlney/wehlney-unity-packages.git?path=/eventbus/com.wehlney.eventbus.reflex#v0.1.0" +"com.wehlney.eventbus": "https://github.com/Wehlney/unity-packages.git?path=/eventbus/com.wehlney.eventbus#v0.1.0", +"com.wehlney.eventbus.purrnet": "https://github.com/Wehlney/unity-packages.git?path=/eventbus/com.wehlney.eventbus.purrnet#v0.1.0", +"com.wehlney.eventbus.reflex": "https://github.com/Wehlney/unity-packages.git?path=/eventbus/com.wehlney.eventbus.reflex#v0.1.0" ``` Install the core package first, then the PurrNet extension, then the Reflex adapter. ## Versioning -Keep each `package.json` version aligned with the Git tag unless intentionally versioning packages independently. +Release tags currently version this repository as a whole. Keep each `package.json` version aligned with the tag unless a package is intentionally versioned on its own. -Recommended first tag: - -```powershell -git tag v0.1.0 -git push origin v0.1.0 -``` - -## Publishing Checklist +## Publishing checklist - Commit all `.meta` files. - Keep package names stable. diff --git a/eventbus/com.wehlney.eventbus.reflex/Runtime/Reflex/PubSubBindings.cs b/eventbus/com.wehlney.eventbus.reflex/Runtime/Reflex/PubSubBindings.cs index 59eb3f7..4c89191 100644 --- a/eventbus/com.wehlney.eventbus.reflex/Runtime/Reflex/PubSubBindings.cs +++ b/eventbus/com.wehlney.eventbus.reflex/Runtime/Reflex/PubSubBindings.cs @@ -1,13 +1,3 @@ -// File: PubSubBindings.cs -// -// Provides DI registration helpers for the PubSub system. -// -// Design rules enforced here: -// - Concrete event types may be registered for full PubSub (Publisher + Subscriber). -// - Interfaces may ONLY be registered as Subscriber. -// - Publishing interface types is explicitly forbidden. -// - using System; using Wehlney.EventBus; using Reflex.Core; @@ -19,22 +9,18 @@ public static class PubSubBindings { /// /// Registers both and for a concrete event type. - /// - /// Interfaces are NOT allowed here. - /// This enforces the architectural rule that only concrete event types may be published. /// - /// - /// The concrete event type to register. - /// Must NOT be an interface. - /// + /// + /// Interfaces are not allowed here. Publishable events must be concrete event records, + /// while interfaces are subscriber-only routes. + /// + /// The concrete event type to register. /// The DI container builder. /// /// Enables sticky behavior for this event type. - /// If enabled, the last published value will be replayed to new subscribers. + /// If enabled, the last published value is replayed to new subscribers. /// - /// - /// Thrown if T is an interface. - /// + /// Thrown if T is an interface. public static PubSubRegistration RegisterPubSub(this ContainerBuilder builder, bool sticky = false) where T : IBaseEvent { @@ -51,20 +37,15 @@ public static PubSubRegistration RegisterPubSub(this ContainerBuilder buil /// /// Registers a only. - /// - /// This method is intended for: - /// - Marker interfaces (e.g. IFailureEvent) - /// - Cross-cutting contracts - /// - Base event abstractions - /// - /// Both interfaces and concrete types are allowed. /// - /// - /// The event type or interface to subscribe to. - /// + /// + /// Use this for marker interfaces, cross-cutting event contracts, and base event + /// abstractions. Both interfaces and concrete event types are valid subscriber routes. + /// + /// The event type or interface to subscribe to. /// The DI container builder. /// - /// Enables sticky behavior for this event type. + /// Enables sticky replay for this subscriber route. /// public static void RegisterSubscriber(this ContainerBuilder builder, bool sticky = false) where T : IEventMarker @@ -79,21 +60,17 @@ public static void RegisterSubscriber(this ContainerBuilder builder, bool sti /// /// Registers a only. - /// - /// Interfaces are NOT allowed. - /// Publishing must always occur through concrete event types. /// - /// - /// The concrete event type to publish. - /// Must NOT be an interface. - /// + /// + /// Interfaces are not allowed. Publishing must happen through concrete event records so + /// routing can dispatch to the concrete type and any registered subscriber interfaces. + /// + /// The concrete event type to publish. /// The DI container builder. /// /// Enables sticky behavior for this event type. /// - /// - /// Thrown if T is an interface. - /// + /// Thrown if T is an interface. public static PubSubRegistration RegisterPublisher(this ContainerBuilder builder, bool sticky = false) where T : IBaseEvent { diff --git a/eventbus/com.wehlney.eventbus.reflex/Runtime/Reflex/PurrNetPubSubBindings.cs b/eventbus/com.wehlney.eventbus.reflex/Runtime/Reflex/PurrNetPubSubBindings.cs index 3d6a9e6..b437e3d 100644 --- a/eventbus/com.wehlney.eventbus.reflex/Runtime/Reflex/PurrNetPubSubBindings.cs +++ b/eventbus/com.wehlney.eventbus.reflex/Runtime/Reflex/PurrNetPubSubBindings.cs @@ -1,5 +1,3 @@ -// File: PurrNetPubSubBindings.cs - using Wehlney.EventBus; using Wehlney.EventBus.PurrNet; using PurrNet.Packing; diff --git a/eventbus/com.wehlney.eventbus/Runtime/Core/EventBus.cs b/eventbus/com.wehlney.eventbus/Runtime/Core/EventBus.cs index a2cac09..64b81da 100644 --- a/eventbus/com.wehlney.eventbus/Runtime/Core/EventBus.cs +++ b/eventbus/com.wehlney.eventbus/Runtime/Core/EventBus.cs @@ -77,10 +77,6 @@ public void Unsubscribe(in SubscriptionToken token) bucket.Remove(token.Index, token.Version); } - // ---------------------------- - // Helpers - // ---------------------------- - private HandlerBucket GetOrCreateBucket(Type key) { if (_buckets.TryGetValue(key, out var bucket)) diff --git a/eventbus/com.wehlney.eventbus/Runtime/Core/Events.cs b/eventbus/com.wehlney.eventbus/Runtime/Core/Events.cs index 8b61887..0fbd01e 100644 --- a/eventbus/com.wehlney.eventbus/Runtime/Core/Events.cs +++ b/eventbus/com.wehlney.eventbus/Runtime/Core/Events.cs @@ -5,31 +5,26 @@ namespace Wehlney.EventBus { - //Base Record & Base Marker /// - /// Root marker interface for the PubSub event system. - /// - /// This interface is intended strictly as a base contract for - /// inheritance and grouping within the PubSub infrastructure. - /// - /// Do NOT use this interface directly as an event type. - /// Always derive a dedicated marker interface or concrete event from it. + /// Root marker interface for the event system. /// + /// + /// Use this only as the base contract for inheritance and grouping. Do not use it + /// directly as an event route; derive a dedicated marker interface or concrete event. + /// public interface IEventMarker { }; public interface IBaseEvent : IEventMarker { } - /// - /// Abstract base record for all concrete publishable events. - /// - /// This type exists solely as an inheritance root for the PubSub system. - /// It must not be used as a standalone event. - /// - /// Always create a specific derived record when defining an event. + /// Base record for concrete publishable events. /// + /// + /// This is the inheritance root for local event records. Define a specific derived + /// record for each event instead of publishing directly. + /// public abstract record LocalEvent : IBaseEvent { public override string ToString() @@ -58,9 +53,6 @@ IEnumerable e when value is not string } } - // Semantics public interface ICommand : IEventMarker { } public interface IStateChange : IEventMarker { } - - // Outcome / Result markers } diff --git a/eventbus/com.wehlney.eventbus/Runtime/Core/Publisher.cs b/eventbus/com.wehlney.eventbus/Runtime/Core/Publisher.cs index ead35c2..24bfb46 100644 --- a/eventbus/com.wehlney.eventbus/Runtime/Core/Publisher.cs +++ b/eventbus/com.wehlney.eventbus/Runtime/Core/Publisher.cs @@ -1,5 +1,3 @@ -// File: Publisher.cs - using System; namespace Wehlney.EventBus @@ -12,8 +10,7 @@ public Publisher(IEventBus bus, bool stickyEnabled) { _bus = bus ?? throw new ArgumentNullException(nameof(bus)); - // HARD GUARD: - // Interfaces are Marker only and shall not be used as Publishers - Use Records instead + // Interfaces are marker routes only; publishers must use concrete event records. if (typeof(T).IsInterface) { throw new InvalidOperationException( diff --git a/eventbus/com.wehlney.eventbus/Runtime/Core/Subscriber.cs b/eventbus/com.wehlney.eventbus/Runtime/Core/Subscriber.cs index 0a29fca..59f6a41 100644 --- a/eventbus/com.wehlney.eventbus/Runtime/Core/Subscriber.cs +++ b/eventbus/com.wehlney.eventbus/Runtime/Core/Subscriber.cs @@ -1,5 +1,3 @@ -// File: Subscriber.cs - using System; namespace Wehlney.EventBus diff --git a/eventbus/com.wehlney.eventbus/Runtime/Core/SubscriptionBag.cs b/eventbus/com.wehlney.eventbus/Runtime/Core/SubscriptionBag.cs index 27fe6eb..d8d85db 100644 --- a/eventbus/com.wehlney.eventbus/Runtime/Core/SubscriptionBag.cs +++ b/eventbus/com.wehlney.eventbus/Runtime/Core/SubscriptionBag.cs @@ -4,8 +4,7 @@ namespace Wehlney.EventBus { /// - /// holds SubscriptionTokens central. - /// No IDisposable-Interfaces -> No Boxing. + /// Owns subscription tokens without storing them as IDisposable, avoiding boxing on dispose. /// public sealed class SubscriptionBag : IDisposable {