stillbox/pkg/sources/source.go

44 lines
668 B
Go
Raw Permalink Normal View History

2024-08-01 01:01:08 -04:00
package sources
import (
"context"
2024-08-03 00:05:02 -04:00
2024-08-05 18:11:31 -04:00
"dynatron.me/x/stillbox/pkg/calls"
2024-08-01 01:01:08 -04:00
"github.com/go-chi/chi/v5"
)
type Source interface {
SourceType() string
}
type sourceInstance struct {
Source
Name string
}
type Sources []sourceInstance
func (s *Sources) Register(name string, src Source) {
*s = append(*s, sourceInstance{
Name: name,
Source: src,
})
}
2024-08-03 00:16:23 -04:00
func (s *Sources) PublicRoutes(r chi.Router) {
2024-08-01 01:01:08 -04:00
for _, si := range *s {
if rs, ok := si.Source.(PublicRouteSource); ok {
rs.InstallPublicRoutes(r)
}
}
}
type Ingestor interface {
Ingest(context.Context, *calls.Call) error
2024-08-01 01:01:08 -04:00
}
type PublicRouteSource interface {
InstallPublicRoutes(chi.Router)
}