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

Move vspd to an internal package. #436

Merged
merged 5 commits into from Sep 16, 2023

Conversation

jholdstock
Copy link
Member

Requires #434

This series of commits culminates in the vspd code being moved to an internal package. Along the way it decouples the webapi package from vspd code, and moves both the webapi and vspd components to a new pattern for starting/stopping subsystems, namely:

var wg sync.WaitGroup
wg.Add(1)
go func() {
	foo_that_blocks_until_ctx_done(ctx)
        wg.Done()
}()
...
wg.Wait()

This is desirable because it is concise and easy to understand. Adding to and removing from waitgroups all in one place is a good practise to be following.

internal/webapi/webapi.go Outdated Show resolved Hide resolved
Creating the essential DB/RPC resources which are required for both
webapi and vspd in the main func allows the two components to be
decoupled.
The vspd Run func is now blocking and returns when its provided context
is cancelled. This means it is invoked/canceled in the same way as the
webapi Run func.

webapi is now created in the main run func rather than within vspd,
further decoupling these components.
Don't log errors returned by server.Shutdown. They are exceedingly
unlikely, and there is nothing which can be done about them.

Moving the "Listening on..." log closer to where the server is actually
started reduces the chance of confusion. Also, logging the parsed
listener.Addr() string instead of the provided config string provides
extra debugging detail.
Copy link
Member

@davecgh davecgh left a comment

Choose a reason for hiding this comment

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

I saw the change to not log the error an admin can't do anything about anyway on server shutdown as well.

@jholdstock jholdstock merged commit 72b0411 into decred:master Sep 16, 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.

None yet

2 participants