mirror of
https://github.com/pocketbase/pocketbase.git
synced 2026-09-08 15:41:18 +02:00
renamed OnClearBootstrap to OnBootstrapClear for consistency with the other hooks
This commit is contained in:
+6
-3
@@ -718,9 +718,12 @@ type App interface {
|
|||||||
// resources (db, app settings, etc).
|
// resources (db, app settings, etc).
|
||||||
OnBootstrap() *hook.Hook[*BootstrapEvent]
|
OnBootstrap() *hook.Hook[*BootstrapEvent]
|
||||||
|
|
||||||
// OnClearBootstrap hook is triggered on unsetting the main application
|
// OnBootstrapClear hook is triggered when clearing the main application
|
||||||
// resources (db, app settings, etc) to their initial nil/empty value.
|
// resources (db connections, cron, logger, etc.)
|
||||||
OnClearBootstrap() *hook.Hook[*BootstrapEvent]
|
//
|
||||||
|
// It is usually invoked automatically right before app termination
|
||||||
|
// or when manually calling app.ClearBootstrap().
|
||||||
|
OnBootstrapClear() *hook.Hook[*BootstrapEvent]
|
||||||
|
|
||||||
// OnServe hook is triggered when the app web server is started
|
// OnServe hook is triggered when the app web server is started
|
||||||
// (after starting the TCP listener but before initializing the blocking serve task),
|
// (after starting the TCP listener but before initializing the blocking serve task),
|
||||||
|
|||||||
+7
-7
@@ -91,7 +91,7 @@ type BaseApp struct {
|
|||||||
|
|
||||||
// app event hooks
|
// app event hooks
|
||||||
onBootstrap *hook.Hook[*BootstrapEvent]
|
onBootstrap *hook.Hook[*BootstrapEvent]
|
||||||
onClearBootstrap *hook.Hook[*BootstrapEvent]
|
onBootstrapClear *hook.Hook[*BootstrapEvent]
|
||||||
onServe *hook.Hook[*ServeEvent]
|
onServe *hook.Hook[*ServeEvent]
|
||||||
onTerminate *hook.Hook[*TerminateEvent]
|
onTerminate *hook.Hook[*TerminateEvent]
|
||||||
onBackupCreate *hook.Hook[*BackupEvent]
|
onBackupCreate *hook.Hook[*BackupEvent]
|
||||||
@@ -251,7 +251,7 @@ func NewBaseApp(config BaseAppConfig) *BaseApp {
|
|||||||
func (app *BaseApp) initHooks() {
|
func (app *BaseApp) initHooks() {
|
||||||
// app event hooks
|
// app event hooks
|
||||||
app.onBootstrap = &hook.Hook[*BootstrapEvent]{}
|
app.onBootstrap = &hook.Hook[*BootstrapEvent]{}
|
||||||
app.onClearBootstrap = &hook.Hook[*BootstrapEvent]{}
|
app.onBootstrapClear = &hook.Hook[*BootstrapEvent]{}
|
||||||
app.onServe = &hook.Hook[*ServeEvent]{}
|
app.onServe = &hook.Hook[*ServeEvent]{}
|
||||||
app.onTerminate = &hook.Hook[*TerminateEvent]{}
|
app.onTerminate = &hook.Hook[*TerminateEvent]{}
|
||||||
app.onBackupCreate = &hook.Hook[*BackupEvent]{}
|
app.onBackupCreate = &hook.Hook[*BackupEvent]{}
|
||||||
@@ -480,7 +480,7 @@ func (app *BaseApp) ClearBootstrap() error {
|
|||||||
event := &BootstrapEvent{}
|
event := &BootstrapEvent{}
|
||||||
event.App = app
|
event.App = app
|
||||||
|
|
||||||
return app.OnClearBootstrap().Trigger(event, func(e *BootstrapEvent) error {
|
return app.OnBootstrapClear().Trigger(event, func(e *BootstrapEvent) error {
|
||||||
type closer interface {
|
type closer interface {
|
||||||
Close() error
|
Close() error
|
||||||
}
|
}
|
||||||
@@ -877,8 +877,8 @@ func (app *BaseApp) OnBootstrap() *hook.Hook[*BootstrapEvent] {
|
|||||||
return app.onBootstrap
|
return app.onBootstrap
|
||||||
}
|
}
|
||||||
|
|
||||||
func (app *BaseApp) OnClearBootstrap() *hook.Hook[*BootstrapEvent] {
|
func (app *BaseApp) OnBootstrapClear() *hook.Hook[*BootstrapEvent] {
|
||||||
return app.onClearBootstrap
|
return app.onBootstrapClear
|
||||||
}
|
}
|
||||||
|
|
||||||
func (app *BaseApp) OnServe() *hook.Hook[*ServeEvent] {
|
func (app *BaseApp) OnServe() *hook.Hook[*ServeEvent] {
|
||||||
@@ -1439,7 +1439,7 @@ func (app *BaseApp) registerBaseHooks() {
|
|||||||
Priority: 999,
|
Priority: 999,
|
||||||
})
|
})
|
||||||
|
|
||||||
app.OnClearBootstrap().Bind(&hook.Handler[*BootstrapEvent]{
|
app.OnBootstrapClear().Bind(&hook.Handler[*BootstrapEvent]{
|
||||||
Id: "__pbCronStop__",
|
Id: "__pbCronStop__",
|
||||||
Func: func(e *BootstrapEvent) error {
|
Func: func(e *BootstrapEvent) error {
|
||||||
app.Cron().Stop()
|
app.Cron().Stop()
|
||||||
@@ -1587,7 +1587,7 @@ func (app *BaseApp) initLogger() error {
|
|||||||
app.logger = slog.New(handler)
|
app.logger = slog.New(handler)
|
||||||
|
|
||||||
// attempt to write all queued logs before clearing the application bootstrap state
|
// attempt to write all queued logs before clearing the application bootstrap state
|
||||||
app.OnClearBootstrap().Bind(&hook.Handler[*BootstrapEvent]{
|
app.OnBootstrapClear().Bind(&hook.Handler[*BootstrapEvent]{
|
||||||
Id: "__pbAppLoggerFlushBeforeStop__",
|
Id: "__pbAppLoggerFlushBeforeStop__",
|
||||||
Func: func(e *BootstrapEvent) error {
|
Func: func(e *BootstrapEvent) error {
|
||||||
// extra precaution in case the hook was manually triggered while inside aux db transaction
|
// extra precaution in case the hook was manually triggered while inside aux db transaction
|
||||||
|
|||||||
+3193
-3190
File diff suppressed because it is too large
Load Diff
+2
-2
@@ -144,9 +144,9 @@ func NewTestAppWithConfig(config core.BaseAppConfig) (*TestApp, error) {
|
|||||||
Priority: -99999,
|
Priority: -99999,
|
||||||
})
|
})
|
||||||
|
|
||||||
t.OnClearBootstrap().Bind(&hook.Handler[*core.BootstrapEvent]{
|
t.OnBootstrapClear().Bind(&hook.Handler[*core.BootstrapEvent]{
|
||||||
Func: func(e *core.BootstrapEvent) error {
|
Func: func(e *core.BootstrapEvent) error {
|
||||||
t.registerEventCall("OnClearBootstrap")
|
t.registerEventCall("OnBootstrapClear")
|
||||||
return e.Next()
|
return e.Next()
|
||||||
},
|
},
|
||||||
Priority: -99999,
|
Priority: -99999,
|
||||||
|
|||||||
Reference in New Issue
Block a user