Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed period (".") app name bug. #541

Merged
merged 1 commit into from
Aug 23, 2023
Merged

Fixed period (".") app name bug. #541

merged 1 commit into from
Aug 23, 2023

Conversation

mwhittaker
Copy link
Member

Before this PR, if you go ran a Service Weaver app with a config file that was missing an app name and a binary, the app name would erroneously default to ".".

╭──────────────────────────────────────────────────╮
│ DEPLOYMENTS                                      │
├─────┬──────────────────────────────────────┬─────┤
│ APP │ DEPLOYMENT                           │ AGE │
├─────┼──────────────────────────────────────┼─────┤
│ .   │ 10695f3a-0afe-4361-8d9a-033fd6ea81a0 │ 2s  │
╰─────┴──────────────────────────────────────┴─────╯
╭────────────────────────────────────────────────╮
│ COMPONENTS                                     │
├─────┬────────────┬──────────────┬──────────────┤
│ APP │ DEPLOYMENT │ COMPONENT    │ REPLICA PIDS │
├─────┼────────────┼──────────────┼──────────────┤
│ .   │ 10695f3a   │ weaver.Main  │ 2417098      │
│ .   │ 10695f3a   │ collatz.Even │ 2417098      │
│ .   │ 10695f3a   │ collatz.Odd  │ 2417098      │
│ .   │ 10695f3a   │ main         │ 2417098      │
╰─────┴────────────┴──────────────┴──────────────╯
╭──────────────────────────────────────────────╮
│ LISTENERS                                    │
├─────┬────────────┬──────────┬────────────────┤
│ APP │ DEPLOYMENT │ LISTENER │ ADDRESS        │
├─────┼────────────┼──────────┼────────────────┤
│ .   │ 10695f3a   │ collatz  │ 127.0.0.1:9000 │
╰─────┴────────────┴──────────┴────────────────╯

To calculate the app name, we called filepath.Base on the binary, but if the binary was empty, filepath.Base would return ".". This PR fixes the bug by only setting the app name if the binary is present.

@mwhittaker mwhittaker requested a review from rgrandl August 18, 2023 16:47
@mwhittaker mwhittaker self-assigned this Aug 18, 2023
Copy link
Contributor

@rgrandl rgrandl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to explicitly require the name of the binary in the config at some point.

Before this PR, if you go ran a Service Weaver app with a config file
that was missing an app name and a binary, the app name would
erroneously default to ".".

```
╭──────────────────────────────────────────────────╮
│ DEPLOYMENTS                                      │
├─────┬──────────────────────────────────────┬─────┤
│ APP │ DEPLOYMENT                           │ AGE │
├─────┼──────────────────────────────────────┼─────┤
│ .   │ 10695f3a-0afe-4361-8d9a-033fd6ea81a0 │ 2s  │
╰─────┴──────────────────────────────────────┴─────╯
╭────────────────────────────────────────────────╮
│ COMPONENTS                                     │
├─────┬────────────┬──────────────┬──────────────┤
│ APP │ DEPLOYMENT │ COMPONENT    │ REPLICA PIDS │
├─────┼────────────┼──────────────┼──────────────┤
│ .   │ 10695f3a   │ weaver.Main  │ 2417098      │
│ .   │ 10695f3a   │ collatz.Even │ 2417098      │
│ .   │ 10695f3a   │ collatz.Odd  │ 2417098      │
│ .   │ 10695f3a   │ main         │ 2417098      │
╰─────┴────────────┴──────────────┴──────────────╯
╭──────────────────────────────────────────────╮
│ LISTENERS                                    │
├─────┬────────────┬──────────┬────────────────┤
│ APP │ DEPLOYMENT │ LISTENER │ ADDRESS        │
├─────┼────────────┼──────────┼────────────────┤
│ .   │ 10695f3a   │ collatz  │ 127.0.0.1:9000 │
╰─────┴────────────┴──────────┴────────────────╯
```

To calculate the app name, we called `filepath.Base` on the binary, but
if the binary was empty, `filepath.Base` would return `"."`. This PR
fixes the bug by only setting the app name if the binary is present.
@mwhittaker
Copy link
Member Author

I would prefer to explicitly require the name of the binary in the config at some point.

The weird thing about SERVICEWEAVER_CONFIG=weaver.toml go run is that the binary in weaver.toml is ignored. So I think it makes some sense to not require it. But it is inconsistent and a bit weird.

@mwhittaker mwhittaker merged commit a272bc4 into main Aug 23, 2023
@mwhittaker mwhittaker deleted the app_name_bug branch August 23, 2023 17:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants