split into separate files

This commit is contained in:
Elijah Duffy
2025-05-30 11:03:44 -07:00
parent f439247631
commit 2f702cccd4
3 changed files with 224 additions and 222 deletions

30
subsystem.go Normal file
View File

@@ -0,0 +1,30 @@
package app
// Subsystem represents a sub-system of the application, with its setup and
// teardown functions and dependencies.
type Subsystem struct {
name string
setup setupFn
teardown teardownFn
depends []*Subsystem
}
// SubsystemOpts contains user-exposed options when defining a subsystem.
type SubsystemOpts struct {
// Setup is the setup function for the subsystem.
Setup setupFn
// Teardown is the teardown function for the subsystem.
Teardown teardownFn
// Depends is a list of subsystems that this subsystem depends on.
Depends []*Subsystem
}
// NewSubsystem creates a new Subsystem instance with the given name and options.
func NewSubsystem(name string, opts SubsystemOpts) *Subsystem {
return &Subsystem{
name: name,
setup: opts.Setup,
teardown: opts.Teardown,
depends: opts.Depends,
}
}