From c293994d2b52a50ee3513a6b5b7a4a12f13352d7 Mon Sep 17 00:00:00 2001 From: Gani Georgiev Date: Sat, 8 Jul 2023 20:02:03 +0300 Subject: [PATCH] added hooksPool flag and updated doc comments --- examples/base/main.go | 9 +++++++++ plugins/jsvm/internal/docs/docs.go | 4 ++-- plugins/jsvm/jsvm.go | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/examples/base/main.go b/examples/base/main.go index 4222c16f..fa25643d 100644 --- a/examples/base/main.go +++ b/examples/base/main.go @@ -38,6 +38,14 @@ func main() { "auto restart the app on pb_hooks file change", ) + var hooksPool int + app.RootCmd.PersistentFlags().IntVar( + &hooksPool, + "hooksPool", + 120, + "the total prewarm goja.Runtime instances for the JS app hooks execution", + ) + var migrationsDir string app.RootCmd.PersistentFlags().StringVar( &migrationsDir, @@ -89,6 +97,7 @@ func main() { MigrationsDir: migrationsDir, HooksDir: hooksDir, HooksWatch: hooksWatch, + HooksPoolSize: hooksPool, }) // migrate command (with js templates) diff --git a/plugins/jsvm/internal/docs/docs.go b/plugins/jsvm/internal/docs/docs.go index 97a7e454..2778fc8f 100644 --- a/plugins/jsvm/internal/docs/docs.go +++ b/plugins/jsvm/internal/docs/docs.go @@ -95,7 +95,7 @@ declare function routerPre(...middlewares: Array): v type appWithoutHooks = Omit /** - * $app is the current running PocketBase instance that is globally + * ` + "`$app`" + ` is the current running PocketBase instance that is globally * available in each .pb.js file. * * @namespace @@ -302,7 +302,7 @@ declare class Dao implements daos.Dao { // ------------------------------------------------------------------- /** - * $dbx defines common utility for working with the DB abstraction. + * ` + "`$dbx`" + ` defines common utility for working with the DB abstraction. * For examples and guides please check the [Database guide](https://pocketbase.io/docs/js-database). * * @group PocketBase diff --git a/plugins/jsvm/jsvm.go b/plugins/jsvm/jsvm.go index caed656f..a4e3cb82 100644 --- a/plugins/jsvm/jsvm.go +++ b/plugins/jsvm/jsvm.go @@ -48,7 +48,7 @@ type Config struct { // If not set it fallbacks to a relative "pb_data/../pb_hooks" directory. HooksDir string - // HooksPoolSize specifies how many goja.Runtime instances to preinit + // HooksPoolSize specifies how many goja.Runtime instances to prewarm // and keep for the JS app hooks gorotines execution. // // Zero or negative value means that it will create a new goja.Runtime