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

vspd: Introduce vspd struct. #409

Merged
merged 2 commits into from
Aug 23, 2023
Merged

vspd: Introduce vspd struct. #409

merged 2 commits into from
Aug 23, 2023

Conversation

jholdstock
Copy link
Member

@jholdstock jholdstock commented Aug 22, 2023

Storing all of the essential resources such as db, rpcs and logger in a vspd struct enables vspd functions to be called without passing a bunch of parameters unnecessarily. This will be increasingly useful later when further changes are introduced.

Requires #408 and #410

@jholdstock jholdstock changed the title New vspd: Introduce vspd struct. Aug 22, 2023
cmd/vspd/main.go Outdated Show resolved Hide resolved
cmd/vspd/main.go Outdated
// stops all started services when a shutdown is requested.
func (v *vspd) run() int {

v.log.Criticalf("Version %s (Go version %s %s/%s)", version.String(), runtime.Version(),
Copy link
Member

Choose a reason for hiding this comment

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

Critical is supposed to be for fatal failures. Most libs even do full on aborts os.Exit style on critical. For example, see how wallet only uses it with the Fatal family of funcs when implementing the stdlib interface.

I know the code was already this way, but it's not really correct.

Copy link
Member Author

Choose a reason for hiding this comment

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

I wanted to ensure that startup and shutdown messages are always logged regardless of the level set in config - is there any other way to achieve this? I got the idea from another dcr* repo (I have a feeling it was dcrdex or dcrlnd) but I cant find it now.

I've only seen the "log and abort" behaviour on Fatal, never on Critical. Both the stdlib logger and the testing package do this. I had interpreted the difference as "this error is fatal and cannot be recovered" vs "this message is critical and must be logged".

One could also argue that considering the point of view of a sysadmin or a monitoring solution, the application completely shutting down really is a more important thing to be aware of than it encountering a recoverable error.

cmd/vspd/main.go Outdated Show resolved Hide resolved
cmd/vspd/main.go Outdated Show resolved Hide resolved
Storing all of the essential resources such as db, rpcs and logger in a
vspd struct enables vspd functions to be called without passing a bunch
of parameters unnecessarily. This will be increasingly useful later when
further changes are introduced.
Moving all vspd code into its own vspd.go file (fka background.go). This
leaves main.go as a minimal entry point for the vspd executable.
@jholdstock jholdstock merged commit b1fbced into decred:master Aug 23, 2023
2 checks passed
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.

3 participants