Skip to content

Commit

Permalink
config: add Config.Proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
Wessie committed Dec 24, 2024
1 parent a95a353 commit 8d4376a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ type Config struct {
Tracker radio.ListenerTrackerService
Queue radio.QueueService
IRC radio.AnnounceService
Proxy radio.ProxyService
}

type reload struct {
Expand All @@ -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
Expand Down
20 changes: 20 additions & 0 deletions config/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 8d4376a

Please sign in to comment.