Skip to content

Commit

Permalink
Remove unused Provider
Browse files Browse the repository at this point in the history
  • Loading branch information
fortuna committed Oct 29, 2024
1 parent 76bcf64 commit 866f9c1
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions x/configurl/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,28 +28,22 @@ type Config struct {
BaseConfig *Config
}

// Provider creates an instance from a config.
type Provider[ObjectType any] interface {
NewInstance(ctx context.Context, config *Config) (ObjectType, error)
}

// BuildFunc is a convenience type for functions that create a instances of ObjectType given a [Config].
// BuildFunc is a function that creates an instance of ObjectType given a [Config].
type BuildFunc[ObjectType any] func(ctx context.Context, config *Config) (ObjectType, error)

// TypeRegistry registers config types.
type TypeRegistry[ObjectType any] interface {
RegisterType(subtype string, newInstance BuildFunc[ObjectType]) error
}

// ExtensibleProvider is [Provider] implementation that can be extended via its [TypeRegistry] interface.
// ExtensibleProvider creates instances of ObjectType in a way that can be extended via its [TypeRegistry] interface.
type ExtensibleProvider[ObjectType comparable] struct {
// Instance to return when config is nil.
BaseInstance ObjectType
builders map[string]BuildFunc[ObjectType]
}

var (
_ Provider[any] = (*ExtensibleProvider[any])(nil)
_ BuildFunc[any] = (*ExtensibleProvider[any])(nil).NewInstance
_ TypeRegistry[any] = (*ExtensibleProvider[any])(nil)
)
Expand Down

0 comments on commit 866f9c1

Please sign in to comment.