-
-
Notifications
You must be signed in to change notification settings - Fork 514
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
cmd/dolt/commands/sqlserver: Restructure the start up sequence for sql-server. #7004
Conversation
…l-server. We explicitly model Services, which can have an Init step, a Run step and a Stop step. Every registered service get initialized in the order they were registered in, then they all run concurrently until Stop is called, when they all get Stopped in reverse order. It's possible for clients to wait for init to be completed and be delivered any errors encountered on startup. They can also wait for stop, to be delivered any errors encountered on shutdown.
…return for err in Init/Close lambdas.
…ore we init the sql server.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So overall I think there's a good abstraction here, but I'm not wild about the current implementation details. Basically boils down to 3 big points:
- There's leakage from one service's Init to another, e.g. clusterController gets Init'ed by one service then used by the Init of another one. These things should be reasonably self-contained
- There are many Init-only "Services", which is another sign of a leaky abstraction. A thing that just runs an Init block and doesn't even need the cleanup of Close() isn't a service and shouldn't be modeled as one
- The actual services should be better encapsulated with their own types and probably their own files, not just anonymous functions.
Service
should probably be an interface, not a struct with funcs.
Basically I think you need to do a better job modeling and separating the concerns of initialization from the concerns of running a service and cleaning up when it shuts down.
…rSpecified variable in the InitSuperUser step.
…ce instead of a struct. Experiment with ServiceState and more rigorous cleanup of some services.
…tesapi servers if we never get to the run step.
… mySQLServer instance, even if we never get to the service which is responsible for running it.
…concurrently and multiple times and it never returns an error.
I moved Service to an interface but I ended up leaving all the existing uses as instances of a struct implementation. When I teased things apart a bit further, if felt like I was getting less readable code, à la http://number-none.com/blow/john_carmack_on_inlined_code.html ...which, to be fair, we do have some gross mutations in here. |
@coffeegoddd DOLT
|
@coffeegoddd DOLT
|
We explicitly model Services, which can have an Init step, a Run step and a Stop step. Every registered service get initialized in the order they were registered in, then they all run concurrently until Stop is called, when they all get Stopped in reverse order. It's possible for clients to wait for init to be completed and be delivered any errors encountered on startup. They can also wait for stop, to be delivered any errors encountered on shutdown.