AutoMixin¶
AutoMixin is the recommended base class for all xcore plugins. It composes every mixin and dispatch mechanism into a single class so that plugin authors only ever write one import and one class Plugin(AutoMixin): declaration.
Import¶
Definition¶
The MRO ensures each mixin's on_load and on_unload run in order via cooperative super() chaining.
Lifecycle methods¶
These are inherited from the mixin chain. Override them in Plugin to add custom logic — always call await super():
Warning
Forgetting await super().on_load() will silently skip all mixin registrations — events, hooks, scheduled jobs, and health checks will not be set up.
Inherited capabilities¶
By inheriting AutoMixin, your Plugin class gains:
| Mixin | What you get |
|---|---|
EventMixin |
@on_event handler registration, self.ctx.events |
HookMixin |
@on_hook handler registration, self.ctx.hooks |
ObservabilityMixin |
self.logger, @health_check registration |
ScheduledMixin |
@cron and @interval job scheduling |
RoutedPlugin |
@route HTTP handler, get_router(), RouterIn() |
AutoDispatchMixin |
@action handler, handle(action_name, payload) |
TrustedBase |
get_service(), call_plugin(), self.ctx injection |
get_router()¶
Returns a FastAPI APIRouter pre-populated with all @route-decorated methods.
AutoMixin pre-implements this as return self.RouterIn() so you don't need to override it.
handle()¶
Dispatches an action by name:
Raises KeyError if the action is not registered.
Minimal plugin example¶
Using individual mixins¶
If you need only a subset of capabilities, import and compose mixins manually:
This avoids pulling in the scheduler or router if the plugin doesn't need them.