forked from wrenn/wrenn
Refactored to maintain a separate cloud version
Moves 12 packages from internal/ to pkg/ (config, id, validate, events, db, auth, lifecycle, scheduler, channels, audit, service) so they can be imported by the enterprise repo as a Go module dependency. Introduces pkg/cpextension (shared Extension interface + ServerContext) and pkg/cpserver (Run() entrypoint with functional options) so the enterprise main.go can call cpserver.Run(cpserver.WithExtensions(...)) without duplicating the 20-step server bootstrap. Adds db/migrations/embed.go for go:embed access to OSS SQL migrations from the enterprise module. cmd/control-plane/main.go is reduced to a 10-line wrapper around cpserver.Run.
This commit is contained in:
27
pkg/cpserver/options.go
Normal file
27
pkg/cpserver/options.go
Normal file
@ -0,0 +1,27 @@
|
||||
package cpserver
|
||||
|
||||
// options holds the configuration for Run.
|
||||
type options struct {
|
||||
version string
|
||||
commit string
|
||||
extensions []Extension
|
||||
}
|
||||
|
||||
// Option configures the control plane server.
|
||||
type Option func(*options)
|
||||
|
||||
// WithVersion sets the version and commit strings for logging.
|
||||
func WithVersion(version, commit string) Option {
|
||||
return func(o *options) {
|
||||
o.version = version
|
||||
o.commit = commit
|
||||
}
|
||||
}
|
||||
|
||||
// WithExtensions registers one or more extensions that add routes and
|
||||
// background workers to the control plane.
|
||||
func WithExtensions(exts ...Extension) Option {
|
||||
return func(o *options) {
|
||||
o.extensions = append(o.extensions, exts...)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user