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..c3cb308 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; @@ -18,23 +8,9 @@ namespace Wehlney.EventBus.Reflex 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. + /// Registers publisher and subscriber bindings for a concrete event type; sticky bindings replay the last value to late subscribers. /// - /// - /// The concrete event type to register. - /// Must NOT be an interface. - /// - /// The DI container builder. - /// - /// Enables sticky behavior for this event type. - /// If enabled, the last published value will be replayed to new subscribers. - /// - /// - /// Thrown if T is an interface. - /// + /// Thrown when T is an interface. public static PubSubRegistration RegisterPubSub(this ContainerBuilder builder, bool sticky = false) where T : IBaseEvent { @@ -50,22 +26,8 @@ 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. + /// Registers a subscriber binding. Interfaces are allowed for marker or cross-cutting event routes. /// - /// - /// The event type or interface to subscribe to. - /// - /// The DI container builder. - /// - /// Enables sticky behavior for this event type. - /// public static void RegisterSubscriber(this ContainerBuilder builder, bool sticky = false) where T : IEventMarker { @@ -78,22 +40,9 @@ public static void RegisterSubscriber(this ContainerBuilder builder, bool sti } /// - /// Registers a only. - /// - /// Interfaces are NOT allowed. - /// Publishing must always occur through concrete event types. + /// Registers a publisher binding for a concrete event type. /// - /// - /// The concrete event type to publish. - /// Must NOT be an interface. - /// - /// The DI container builder. - /// - /// Enables sticky behavior for this event type. - /// - /// - /// Thrown if T is an interface. - /// + /// Thrown when 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..5274c30 100644 --- a/eventbus/com.wehlney.eventbus/Runtime/Core/Events.cs +++ b/eventbus/com.wehlney.eventbus/Runtime/Core/Events.cs @@ -5,15 +5,8 @@ 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 for event contracts. Use a derived marker or concrete event type instead of this interface directly. /// public interface IEventMarker { @@ -21,14 +14,8 @@ 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. /// public abstract record LocalEvent : IBaseEvent { @@ -58,9 +45,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 {