Documentation
¶
Overview ¶
Package comments is the official comment-system module: per-content discussion with moderation (pending/approved/rejected/spam).
Index ¶
- Constants
- type Module
- func (m *Module) AdminManifest() kernel.AdminExtensionManifest
- func (m *Module) AgentHandler() *agent.CommentHandler
- func (m *Module) BrowserHandler() *api.CommentHandler
- func (m *Module) Init(_ kernel.Kernel) error
- func (m *Module) Migrations() fs.FS
- func (m *Module) Name() string
- func (m *Module) Optional() []string
- func (m *Module) Requires() []string
- func (m *Module) Service() *commentdomain.Service
- func (m *Module) Shutdown() error
- func (m *Module) Version() string
- type Option
- func WithAgentContentLookup(lookup agent.ContentLookup) Option
- func WithAgentRoles(roles agent.RoleCapabilities) Option
- func WithContentResolver(resolve api.ContentResolver) Option
- func WithLogger(logger kernel.Logger) Option
- func WithRoles(roles api.RoleCapabilities) Option
- func WithService(service *commentdomain.Service) Option
Constants ¶
const ( // Name is the registry key for this module. Name = "comments" // Version is the module version reported via Module.Version. Version = "0.1.0" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Module ¶
type Module struct {
// contains filtered or unexported fields
}
Module is the comments kernel module.
func New ¶
New builds the module, adopting the composition root's wiring. Both realm handlers are built once here so routes serve the same instances.
func (*Module) AdminManifest ¶
func (m *Module) AdminManifest() kernel.AdminExtensionManifest
AdminManifest declares this module's admin-shell extensions: the comments moderation navigation entry.
func (*Module) AgentHandler ¶
func (m *Module) AgentHandler() *agent.CommentHandler
AgentHandler exposes the Bearer-realm handler for core mounting, alongside the browser handler for the same per-group reason.
func (*Module) BrowserHandler ¶
func (m *Module) BrowserHandler() *api.CommentHandler
BrowserHandler exposes the JWT/CSRF-realm handler for core mounting. Core mounts it explicitly (rather than via RouteProvider) because the comment surface spans four middleware groups plus the agent realm, which a single RegisterRoutes call cannot express.
func (*Module) Init ¶
Init wires the module. The handlers are already built by New; Init only validates presence. Migration execution is core-driven (it needs the live *sql.DB, which modules never touch directly).
func (*Module) Migrations ¶
Migrations returns the embedded migration filesystem, laid out per driver ({sqlite,postgresql,mysql}/NNN_name.{up,down}.sql). The core runner tracks each module in its own schema_migrations_<module> table.
func (*Module) Requires ¶
Requires lists hard dependencies. Comments reference content items and users loosely (owner/content IDs without foreign-key enforcement), but the wrapper graph this module replaces declared users — keep the edge so the composition resolves identically.
func (*Module) Service ¶
func (m *Module) Service() *commentdomain.Service
Service exposes the adopted domain service for composition-root wiring. It stays valid for the module's lifetime.
type Option ¶
type Option func(*Module)
Option configures a Module. The composition root supplies every option; direct construction without options yields a standalone module that serves nothing (handlers built over nil dependencies must not be invoked).
func WithAgentContentLookup ¶
func WithAgentContentLookup(lookup agent.ContentLookup) Option
WithAgentContentLookup attaches the content lookup for the agent handlers. Without one content-scoped endpoints fail at lookup time.
func WithAgentRoles ¶
func WithAgentRoles(roles agent.RoleCapabilities) Option
WithAgentRoles attaches the role registry for the agent comment gate. It is a separate option (rather than sharing WithRoles) because the two api packages own their seams independently; core satisfies both with one adapter.
func WithContentResolver ¶
func WithContentResolver(resolve api.ContentResolver) Option
WithContentResolver attaches the published-content lookup for the browser handlers. Without one content-scoped endpoints fail at lookup time.
func WithLogger ¶
WithLogger attaches the module logger. Without one handler failures are dropped (discard sink).
func WithRoles ¶
func WithRoles(roles api.RoleCapabilities) Option
WithRoles attaches the role registry for the browser comment gate. Without one every authenticated caller may post comments (the legacy behavior).
func WithService ¶
func WithService(service *commentdomain.Service) Option
WithService adopts the comments domain service (composition root). The same instance backs the browser and agent handlers so validation, the AllowComments gate, and moderation transitions run identically in both realms.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package admin owns this module's admin-shell manifest: the declarative UI the single admin SPA renders for comments.
|
Package admin owns this module's admin-shell manifest: the declarative UI the single admin SPA renders for comments. |
|
Package store is the single-source comment repository: one implementation against *sql.DB plus a kernel Dialect, replacing the three per-driver copies.
|
Package store is the single-source comment repository: one implementation against *sql.DB plus a kernel Dialect, replacing the three per-driver copies. |
|
Package testutil provides the kernel fixture module tests run against.
|
Package testutil provides the kernel fixture module tests run against. |