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

Initialize DB when VATZ is initialized. #425

Merged
merged 2 commits into from
Apr 11, 2023
Merged

Conversation

rootwarp
Copy link
Member

@rootwarp rootwarp commented Apr 4, 2023

1. Type of change

Please delete options that are not relevant.

  • New feature
  • Enhancement
  • Bug/fix (non-breaking change which fixes an issue)
  • others (anything other than above)

2. Summary

Please include a summary of the changes and which issue is fixed or solved.

Related: # (issue)

close #421

Summary

Initialize DB when vatz init executed.


3. Comments

Please, leave a comments if there's further action that requires.

@rootwarp
Copy link
Member Author

rootwarp commented Apr 4, 2023

ok      github.com/dsrvlabs/vatz/utils  (cached)
?       github.com/dsrvlabs/vatz        [no test files]
ok      github.com/dsrvlabs/vatz/cmd    3.137s  coverage: 19.1% of statements
ok      github.com/dsrvlabs/vatz/manager/api    0.501s  coverage: 0.0% of statements [no tests to run]
ok      github.com/dsrvlabs/vatz/manager/config 0.268s  coverage: 91.2% of statements
ok      github.com/dsrvlabs/vatz/manager/dispatcher     0.894s  coverage: 7.8% of statements
ok      github.com/dsrvlabs/vatz/manager/executor       1.144s  coverage: 68.9% of statements
ok      github.com/dsrvlabs/vatz/manager/healthcheck    0.628s  coverage: 46.5% of statements
ok      github.com/dsrvlabs/vatz/manager/plugin 7.026s  coverage: 67.4% of statements
?       github.com/dsrvlabs/vatz/manager/types  [no test files]
?       github.com/dsrvlabs/vatz/mocks  [no test files]
ok      github.com/dsrvlabs/vatz/monitoring/prometheus  1.300s  coverage: 0.0% of statements
ok      github.com/dsrvlabs/vatz/rpc    2.632s  coverage: 67.2% of statements
ok      github.com/dsrvlabs/vatz/utils  1.671s  coverage: 13.3% of statements
go build -ldflags="-X 'github.com/dsrvlabs/vatz/utils.Version=issue#421' -X 'github.com/dsrvlabs/vatz/utils.Commit=a06a1fe'" -v
rootwarp@Mindhack2021 ~/g/d/vatz issue#421 >

@rootwarp rootwarp requested a review from a team April 4, 2023 06:52
@rootwarp rootwarp self-assigned this Apr 4, 2023
Copy link
Member

@heejin-github heejin-github left a comment

Choose a reason for hiding this comment

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

LGTM

@xellos00
Copy link
Member

xellos00 commented Apr 7, 2023

@rootwarp
I think I should have catch this error,
but is this command shouldn't valid for when I init to other directory?

or we skipped --home command?

 ./vatz init --home /Users/dongyookang/test
Error: unknown flag: --home
Usage:
   init [flags]

Flags:
  -h, --help            help for init
  -o, --output string   New config file to create (default "default.yaml")

panic: unknown flag: --home

goroutine 1 [running]:
main.main()
        /Users/dongyookang/ffplay/GolandProjects/dsrvlabs/vatz/main.go:20 +0x3a
 ✘ dongyookang DK 🚀   ~/ffplay/GolandProjects/dsrvlabs/vatz   main ✚
 

@rootwarp
Copy link
Member Author

rootwarp commented Apr 8, 2023

@rootwarp I think I should have catch this error, but is this command shouldn't valid for when I init to other directory?

or we skipped --home command?

 ./vatz init --home /Users/dongyookang/test
Error: unknown flag: --home
Usage:
   init [flags]

Flags:
  -h, --help            help for init
  -o, --output string   New config file to create (default "default.yaml")

panic: unknown flag: --home

goroutine 1 [running]:
main.main()
        /Users/dongyookang/ffplay/GolandProjects/dsrvlabs/vatz/main.go:20 +0x3a
 ✘ dongyookang DK 🚀   ~/ffplay/GolandProjects/dsrvlabs/vatz   main ✚
 

@xellos00 Thanks for the review.
--home flag should be available, so I'll be back with a new commit. 👍

@rootwarp
Copy link
Member Author

@xellos00 I'm considering for adding --home flag, but we need to discuss more before implementing it.

When we try to execute vatz start command, we can use --config flag to choose the exact configuration file. So, if we try to make the home directory selectable, the selected directory should be written on the config file and vatz should load home directory and use it to load DB and configs.

Moreover, if we add home field on the config file, we may update other commands because those are just using the VATZ home directory as $HOME/.vatz implicitly.

So, whole steps I expected are,

  1. Add --home flag on init command. The init command initializes DB and creates new configs. And it also adds home field on the new configs.
  2. Update plugin command to load home directory from config.
  3. Update start command to load home directory from config.

@xellos00
Copy link
Member

xellos00 commented Apr 10, 2023

@xellos00 I'm considering for adding --home flag, but we need to discuss more before implementing it.

When we try to execute vatz start command, we can use --config flag to choose the exact configuration file. So, if we try to make the home directory selectable, the selected directory should be written on the config file and vatz should load home directory and use it to load DB and configs.

Moreover, if we add home field on the config file, we may update other commands because those are just using the VATZ home directory as $HOME/.vatz implicitly.

So, whole steps I expected are,

  1. Add --home flag on init command. The init command initializes DB and creates new configs. And it also adds home field on the new configs.
  2. Update plugin command to load home directory from config.
  3. Update start command to load home directory from config.

@rootwarp
In fact, I understood your expected behaviors regarding --home flag in command init, start.
yet I am little bit confused after I read your comment.

let's have further discussion tomorrow for this.
I sent invitation as below.
image

@xellos00
Copy link
Member

Confirmed!!

 dongyookang DK 🚀   ~/ffplay/GolandProjects/dsrvlabs/vatz   issue#421 ±✚
 ./vatz init       
2023-04-11T06:35:58-05:00 INF init module=main
2023-04-11T06:35:58-05:00 INF create file default.yaml module=main
2023-04-11T06:35:58-05:00 INF initDB /Users/dongyookang/.vatz/vatz.db module=db
2023-04-11T06:35:58-05:00 INF newWriter /Users/dongyookang/.vatz/vatz.db module=db
2023-04-11T06:35:58-05:00 INF Create DB Instance module=db
 dongyookang DK 🚀   ~/ffplay/GolandProjects/dsrvlabs/vatz   issue#421 ±✚
 ./vatz plugin list
2023-04-11T06:36:12-05:00 INF List plugins module=plugin
2023-04-11T06:36:12-05:00 INF List module=plugin
2023-04-11T06:36:12-05:00 INF newReader /Users/dongyookang/.vatz/vatz.db module=db
2023-04-11T06:36:12-05:00 INF Create DB Instance module=db
2023-04-11T06:36:12-05:00 INF List Plugin module=db
+------+--------------+------------+---------+
| NAME | INSTALL DATA | REPOSITORY | VERSION |
+------+--------------+------------+---------+
+------+--------------+------------+---------+
 dongyookang DK 🚀   ~/ffplay/GolandProjects/dsrvlabs/vatz   issue#421 ±✚
 

 dongyookang DK 🚀   ~
 ls -al | grep .vatz
drwxr-xr-x    3 dongyookang  staff      96 Apr 11 06:26 .vatz
drwxr-xr-x    5 dongyookang  staff     160 Dec  1 22:11 .vatz_backup
 dongyookang DK 🚀   ~
 rm -rf .vatz     
 dongyookang DK 🚀   ~
 ls -al | grep .vatz
drwxr-xr-x    5 dongyookang  staff     160 Dec  1 22:11 .vatz_backup
 dongyookang DK 🚀   ~
 ls -al | grep .vatz
drwxr-xr-x    3 dongyookang  staff      96 Apr 11 06:35 .vatz
drwxr-xr-x    5 dongyookang  staff     160 Dec  1 22:11 .vatz_backup
 dongyookang DK 🚀   ~
 

@xellos00 xellos00 merged commit ef1ae24 into dsrvlabs:main Apr 11, 2023
@xellos00 xellos00 added Vatz Project Name area:svc Anything related to Vatz Service. type:enhancement Any enhancement for feature or anything labels Apr 11, 2023
@rootwarp rootwarp deleted the issue#421 branch April 11, 2023 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:svc Anything related to Vatz Service. type:enhancement Any enhancement for feature or anything Vatz Project Name
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Initialize database
3 participants