diff --git a/caddy/caddy.go b/caddy/caddy.go index 0d3b21e5..8af78fcc 100644 --- a/caddy/caddy.go +++ b/caddy/caddy.go @@ -49,7 +49,7 @@ func init() { } type workerConfig struct { - // Name for the worker. Default: the filename for FrankenPHPApp workers, always prefixed with "m#" for FrankenPHPModule workers. + // Name for the worker. Default: the filename for FrankenPHPApp workers, always prefixed with "🧩 " for FrankenPHPModule workers. Name string `json:"name,omitempty"` // FileName sets the path to the worker script. FileName string `json:"file_name,omitempty"` @@ -318,8 +318,8 @@ func (f *FrankenPHPApp) UnmarshalCaddyfile(d *caddyfile.Dispenser) error { } wc.Name = name } - if strings.HasPrefix(wc.Name, "m#") { - return fmt.Errorf("global worker names must not start with 'm#': %q", wc.Name) + if strings.HasPrefix(wc.Name, "🧩 ") { + return fmt.Errorf("global worker names must not start with '🧩 ': %q", wc.Name) } // check for duplicate workers for _, existingWorker := range f.Workers { @@ -499,7 +499,7 @@ func (f *FrankenPHPModule) ServeHTTP(w http.ResponseWriter, r *http.Request, _ c } func generateUniqueModuleWorkerName(filepath string) string { - name := "m#" + filepath + name := "🧩 " + filepath i := 0 for { nameExists := false @@ -513,7 +513,7 @@ func generateUniqueModuleWorkerName(filepath string) string { break } i++ - name = fmt.Sprintf("m#%s_%d", filepath, i) + name = fmt.Sprintf("🧩 %s_%d", filepath, i) } return name @@ -607,8 +607,8 @@ func (f *FrankenPHPModule) UnmarshalCaddyfile(d *caddyfile.Dispenser) error { if wc.Name == "" { wc.Name = generateUniqueModuleWorkerName(wc.FileName) } - if !strings.HasPrefix(wc.Name, "m#") { - wc.Name = "m#" + wc.Name + if !strings.HasPrefix(wc.Name, "🧩 ") { + wc.Name = "🧩 " + wc.Name } // Check if a worker with this filename already exists in this module diff --git a/caddy/config_test.go b/caddy/config_test.go index 9a4c9aa2..dc075ee4 100644 --- a/caddy/config_test.go +++ b/caddy/config_test.go @@ -160,8 +160,8 @@ func TestModuleWorkersDifferentNamesSucceed(t *testing.T) { // Verify that both workers were added to moduleWorkerConfigs require.Len(t, moduleWorkerConfigs, 2, "Expected two workers to be added to moduleWorkerConfigs") - require.Equal(t, "m#test-worker-1", moduleWorkerConfigs[0].Name, "First worker should have the correct name") - require.Equal(t, "m#test-worker-2", moduleWorkerConfigs[1].Name, "Second worker should have the correct name") + require.Equal(t, "🧩 test-worker-1", moduleWorkerConfigs[0].Name, "First worker should have the correct name") + require.Equal(t, "🧩 test-worker-2", moduleWorkerConfigs[1].Name, "Second worker should have the correct name") resetModuleWorkers() } @@ -267,8 +267,8 @@ func TestModuleWorkerWithCustomName(t *testing.T) { require.Len(t, module.Workers, 1, "Expected one worker to be added to the module") require.Equal(t, "../testdata/worker-with-env.php", module.Workers[0].FileName, "Worker should have the correct filename") - // Verify that the worker was added to moduleWorkerConfigs with the m# prefix - require.Equal(t, "m#custom-worker-name", module.Workers[0].Name, "Worker should have the custom name") + // Verify that the worker was added to moduleWorkerConfigs with the 🧩 prefix + require.Equal(t, "🧩 custom-worker-name", module.Workers[0].Name, "Worker should have the custom name") resetModuleWorkers() } diff --git a/worker.go b/worker.go index 2cad97de..0f87857a 100644 --- a/worker.go +++ b/worker.go @@ -69,7 +69,7 @@ func initWorkers(opt []workerOpt) error { func getWorkerKey(name string, filename string) string { key := filename - if strings.HasPrefix(name, "m#") { + if strings.HasPrefix(name, "🧩 ") { key = name } return key