mirror of
https://github.com/hanzoai/o11y-foundry.git
synced 2026-11-03 02:08:34 +00:00
#### Summary Introduces a per-Kind `Planner` contract so Foundry can drive multiple casting Kinds through a single pipeline. `Foundry.Forge` / `Cast` / `Gauge` become Kind-agnostic; per-Kind state (registry, moldings, casting strategy, enricher) lives in the Kind's own Planner. #### Changes - New `internal/planner` package defining the `Planner` contract. - `Foundry` holds a `Planners` dispatch map; each casting package implements the contract (`installation.Planner`, `collectionagent.Planner`). - Installation registry moves from `internal/foundry/registry.go` to `internal/casting/installation/registry.go`. - CollectionAgent Kind scaffolded: Planner + collector molding wired end-to-end. No deployment castings yet. - `MoldingKindCollector` added to `api/v1alpha1/molding_kind.go`. Related: https://github.com/SigNoz/platform-pod/issues/1971, https://github.com/SigNoz/platform-pod/issues/1972
52 lines
1.4 KiB
Go
52 lines
1.4 KiB
Go
package collectionagent
|
|
|
|
import (
|
|
"log/slog"
|
|
|
|
"github.com/signoz/foundry/api/v1alpha1"
|
|
foundryerrors "github.com/signoz/foundry/internal/errors"
|
|
"github.com/signoz/foundry/internal/tooler"
|
|
)
|
|
|
|
type CastingItem struct {
|
|
Casting Casting
|
|
Toolers []tooler.Tooler
|
|
}
|
|
|
|
type Registry struct {
|
|
castings map[v1alpha1.TypeDeployment]CastingItem
|
|
}
|
|
|
|
func NewRegistry(logger *slog.Logger) *Registry {
|
|
return &Registry{
|
|
castings: map[v1alpha1.TypeDeployment]CastingItem{},
|
|
}
|
|
}
|
|
|
|
func (registry *Registry) lookup(deployment v1alpha1.TypeDeployment) (CastingItem, bool) {
|
|
if item, ok := registry.castings[deployment]; ok {
|
|
return item, true
|
|
}
|
|
if deployment.Platform != (v1alpha1.Platform{}) {
|
|
item, ok := registry.castings[v1alpha1.TypeDeployment{Mode: deployment.Mode, Flavor: deployment.Flavor}]
|
|
return item, ok
|
|
}
|
|
return CastingItem{}, false
|
|
}
|
|
|
|
func (registry *Registry) Casting(deployment v1alpha1.TypeDeployment) (Casting, error) {
|
|
item, ok := registry.lookup(deployment)
|
|
if !ok {
|
|
return nil, foundryerrors.Newf(foundryerrors.TypeUnsupported, "collectionagent deployment '%+v' is not supported", deployment)
|
|
}
|
|
return item.Casting, nil
|
|
}
|
|
|
|
func (registry *Registry) Toolers(deployment v1alpha1.TypeDeployment) ([]tooler.Tooler, error) {
|
|
item, ok := registry.lookup(deployment)
|
|
if !ok {
|
|
return nil, foundryerrors.Newf(foundryerrors.TypeUnsupported, "collectionagent deployment '%+v' is not supported", deployment)
|
|
}
|
|
return item.Toolers, nil
|
|
}
|