Moving some subsets of commands in dbatools 2.0 #8630
Replies: 4 comments 11 replies
-
This has been my dream for long, I'd happily contribute given I can find time. I think best results, from the module size perspective, can be achieved by separating not just by command type, but also by the underlying libraries (dlls) that support said commands. As an example, replication and DacPac commands both rely on certain dlls that are not invoked anywhere else. The general rule of dbatools was "load everything right away", but with this approach we can shift towards on-demand dll load, which would definitely improve module load time. It can either be split into independent modules, or, at the very least, hide dynamic load in an internal function that calls If we had a script that somehow discovered all dependencies for each command, we could then easily group them by requirements. |
Beta Was this translation helpful? Give feedback.
-
Oh, oof. Okay so now repositories. The only one that maybe could separate out is the library repo which currently looks like this: https://github.com/dataplat/dbatools-library/tree/ci |
Beta Was this translation helpful? Give feedback.
-
Makes sense to me to split them out into separate modules - as for working out all the dependencies that is going to be hard since there is so many that interconnect. Thinking out loud but not fully at this point - do we currently have the right pester tests for each command to ensure everything works after the spilt
|
Beta Was this translation helpful? Give feedback.
-
Can comment briefly at this point (on mobile)... Your build and test process have to consider whether things play nice together with SMO. If a user imports one sub module over the whole module initially or in the same session. The challenge with SMO is identifying the core libraries it has not necessarily our core commands. Certain DLLs cause a core set of SMO namespaces to be imported or required. We have to ensure that plays nice with how the sub modules would both function together but also individually. I would recommend identifying and mapping out the dependencies that SMO has with it's libraries. That is going to affect the import process and tests ability. We need to make sure we don't try to import things that are not already present or forget to package a library with a sub module. |
Beta Was this translation helpful? Give feedback.
-
I've often been asked to separate dbatools into different modules, similar to other large modules.
I've resisted because it's hard to categorize commands and there's so much interrelation.
But now I see there are a couple that are very easy to separate. Those include:
The
Performance Monitor
commandsThe
XESmartTarget
commandsThe
Data Masking and Data Generation
commandsThe
Windows Server Failover Cluster
commandsThe
Replication
commandsMaybe we divide it up by the categories on dbatools.io/commands but combine many of them as .core and .utility? How far do we go? Just the above or the whole way?
This will help dbatools import a lot faster and if you install dbatools, it'll come with all of these, but when you execute
Get-DbaDatabase
, it'll only load dbatools-core behind the scenes. If you runGet-DbaRepDistributor
, it'll load dbatools.core and dbatools.replication submodule. If you want to just installdbatools.replication
, it'll bedbatools.replication
anddbatools.core
.@niphlod would your script that gets interrelated commands be able to tell us what needs to go in dbatools.core? Basically, what commands will be commonly used in the above groups.
Note: I'll soon be submitting a giant PR with my library changes and will love if anyone has the time to review.
/cc @niphlod @sanderstad @andreasjordan @jpomfret @wsmelton @SQLDBAWithABeard @ClaudioESSilva @lancasteradam @nvarscar
(anyone is welcome to contribute -- I just pinged people who are around, whereas others have contributed heavily but aren't around as much.)
Beta Was this translation helpful? Give feedback.
All reactions