Module is the interface every event module must implement. Embed BaseModule to get no-op defaults for optional methods.
| 12 | // Module is the interface every event module must implement. |
| 13 | // Embed BaseModule to get no-op defaults for optional methods. |
| 14 | type Module interface { |
| 15 | // Name returns a human-readable module name (e.g., "Sentry"). |
| 16 | Name() string |
| 17 | |
| 18 | // Type returns the event type string stored in the events table. |
| 19 | Type() string |
| 20 | |
| 21 | // RegisterRoutes adds module-specific API routes to the router. |
| 22 | RegisterRoutes(mux *http.ServeMux, store event.Store) |
| 23 | |
| 24 | // HTTPHandler returns a handler that inspects an incoming request |
| 25 | // and either claims it or returns nil. Return nil if this module |
| 26 | // has no HTTP ingestion (e.g., TCP-only modules). |
| 27 | HTTPHandler() HTTPIngestionHandler |
| 28 | |
| 29 | // TCPServers returns TCP server configurations this module needs. |
| 30 | TCPServers() []tcp.ServerConfig |
| 31 | |
| 32 | // PreviewMapper returns the mapper for converting payloads to previews. |
| 33 | PreviewMapper() event.PreviewMapper |
| 34 | |
| 35 | // RegisterMigrations registers module-specific SQL migration files. |
| 36 | RegisterMigrations(migrator *storage.Migrator) error |
| 37 | |
| 38 | // OnInit is called once at startup after migrations are applied. |
| 39 | OnInit(db *sql.DB) error |
| 40 | |
| 41 | // OnEventStored is called after any event is persisted. |
| 42 | OnEventStored(ev event.Event) |
| 43 | } |
| 44 | |
| 45 | // HTTPIngestionHandler decides if an HTTP request belongs to a module. |
| 46 | type HTTPIngestionHandler interface { |
no outgoing calls
no test coverage detected