feat(party): give every application its own plugin instances (quick-261118-lbt)

- Register keeps a pristine shallow copy of each pointer-to-struct plugin;
  every Activate hands its application a fresh copy, so a second
  application no longer rebinds the first one's plugins
- value plugins and pointers to non-struct types are used as is
- party.RegisterFactory for plugins whose init builds maps or pointers
- activate() and its tests are unchanged
- README and plugin/lifecycle docs describe the per-application rule
This commit is contained in:
Jakub Zych
2026-11-18 15:37:06 +01:00
parent 4d3b1e9f62
commit ea1befdd6c
5 changed files with 347 additions and 16 deletions

View File

@@ -37,7 +37,7 @@ This is the WinterCMS `register` and `boot` split: when any Boot runs, every plu
## The container
`backpack.App` is the application container that Register and Boot receive. It holds the configuration in `backpack.App.Config`, the event bus in `backpack.App.Events` and a typed service registry. Nothing in it is process-global, so two applications in one test do not share state.
`backpack.App` is the application container that Register and Boot receive. It holds the configuration in `backpack.App.Config`, the event bus in `backpack.App.Events` and a typed service registry. Nothing in it is process-global, so two applications in one test do not share state. `party.Activate` also gives each application its own plugin instances, so plugin state is not shared either.
Services are keyed by their Go type. A plugin publishes a value with `backpack.App.Publish` and another plugin reads it with `backpack.App.Lookup` and the same type argument. Publish under an interface type when consumers should not depend on your implementation: