diff --git a/config/config.go b/config/config.go index 04b4f30..218c152 100644 --- a/config/config.go +++ b/config/config.go @@ -293,6 +293,7 @@ type Config struct { Tracker radio.ListenerTrackerService Queue radio.QueueService IRC radio.AnnounceService + Proxy radio.ProxyService } type reload struct { @@ -316,6 +317,7 @@ func newConfig(c config) Config { cfg.Tracker = newTrackerService(cfg) cfg.Queue = newQueueService(cfg, streamerConn) cfg.IRC = newIRCService(cfg) + cfg.Proxy = newProxyService(cfg) cfg.StoreConf(c) return cfg diff --git a/config/rpc.go b/config/rpc.go index ee677a2..0fdddf6 100644 --- a/config/rpc.go +++ b/config/rpc.go @@ -72,6 +72,26 @@ func (m *managerService) UpdateFromStorage(ctx context.Context) error { var _ radio.ManagerService = &managerService{} +func newProxyService(cfg Config) radio.ProxyService { + return &proxyService{ + Value(cfg, func(c Config) radio.ProxyService { + return rpc.NewProxyService(rpc.PrepareConn(cfg.Conf().Proxy.RPCAddr.String())) + }), + } +} + +type proxyService struct { + fn func() radio.ProxyService +} + +func (p *proxyService) MetadataStream(ctx context.Context) (eventstream.Stream[radio.ProxyMetadataEvent], error) { + return p.fn().MetadataStream(ctx) +} + +func (p *proxyService) SourceStream(ctx context.Context) (eventstream.Stream[radio.ProxySourceEvent], error) { + return p.fn().SourceStream(ctx) +} + func newStreamerService(cfg Config, conn func() *grpc.ClientConn) radio.StreamerService { return &streamerService{ Value(cfg, func(c Config) radio.StreamerService {