manager

package
v0.0.0-...-fd00b2c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 4, 2024 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ExecuteListener = NewListener

ExecuteListener is an alias for NewListener

Functions

func Execute

func Execute(ctx context.Context, cfg config.Config) error

Execute executes a manager with the context and configuration given; it returns with any error that occurs; Execution can be interrupted by canceling the context given.

func NewHTTPServer

func NewHTTPServer(m *Manager) (*grpc.Server, error)

NewHTTPServer sets up a net/http server ready to serve RPC requests

Types

type IcecastStatus

type IcecastStatus struct {
	Icestats struct {
		Admin              string `json:"admin"`
		Host               string `json:"host"`
		Location           string `json:"location"`
		ServerID           string `json:"server_id"`
		ServerStart        string `json:"server_start"`
		ServerStartIso8601 string `json:"server_start_iso8601"`
		Source             []struct {
			AudioInfo          string `json:"audio_info,omitempty"`
			Bitrate            int    `json:"bitrate,omitempty"`
			Channels           int    `json:"channels,omitempty"`
			Genre              string `json:"genre"`
			ListenerPeak       int    `json:"listener_peak"`
			Listeners          int    `json:"listeners"`
			Listenurl          string `json:"listenurl"`
			Samplerate         int    `json:"samplerate,omitempty"`
			ServerDescription  string `json:"server_description"`
			ServerName         string `json:"server_name"`
			ServerType         string `json:"server_type"`
			ServerURL          string `json:"server_url,omitempty"`
			StreamStart        string `json:"stream_start"`
			StreamStartIso8601 string `json:"stream_start_iso8601"`
			Title              string `json:"title"`
		} `json:"source"`
	} `json:"icestats"`
}

func FetchIcecastStatus

func FetchIcecastStatus(ctx context.Context, uri string) (IcecastStatus, error)

FetchIcecastStatus fetches the status page of an icecast server. This requires an icecast server version equal to or higher than 2.4

type Listener

type Listener struct {
	config.Config
	// contains filtered or unexported fields
}

Listener listens to an icecast mp3 stream with interleaved song metadata

func NewListener

func NewListener(ctx context.Context, cfg config.Config, m radio.ManagerService) *Listener

NewListener creates a listener and starts running in the background immediately

func (*Listener) Shutdown

func (ln *Listener) Shutdown() error

Shutdown signals the listener to stop running, and waits for it to exit

type Manager

type Manager struct {
	config.Config

	Storage radio.StorageService
	// contains filtered or unexported fields
}

Manager manages shared state between different processes

func NewManager

func NewManager(ctx context.Context, cfg config.Config) (*Manager, error)

NewManager returns a manager ready for use

func (*Manager) CurrentListeners

func (m *Manager) CurrentListeners(ctx context.Context) (eventstream.Stream[radio.Listeners], error)

func (*Manager) CurrentSong

func (m *Manager) CurrentSong(ctx context.Context) (eventstream.Stream[*radio.SongUpdate], error)

func (*Manager) CurrentStatus

func (m *Manager) CurrentStatus(ctx context.Context) (eventstream.Stream[radio.Status], error)

func (*Manager) CurrentThread

func (m *Manager) CurrentThread(ctx context.Context) (eventstream.Stream[radio.Thread], error)

func (*Manager) CurrentUser

func (m *Manager) CurrentUser(ctx context.Context) (eventstream.Stream[*radio.User], error)

func (*Manager) Status

func (m *Manager) Status(ctx context.Context) (*radio.Status, error)

Status returns the current status of the radio

func (*Manager) UpdateListeners

func (m *Manager) UpdateListeners(ctx context.Context, listeners radio.Listeners) error

UpdateListeners sets the listener count

func (*Manager) UpdateSong

func (m *Manager) UpdateSong(ctx context.Context, update *radio.SongUpdate) error

UpdateSong sets information about the currently playing song

func (*Manager) UpdateThread

func (m *Manager) UpdateThread(ctx context.Context, thread radio.Thread) error

UpdateThread sets the current thread information on the front page and chats

func (*Manager) UpdateUser

func (m *Manager) UpdateUser(ctx context.Context, u *radio.User) error

UpdateUser sets information about the current streamer

type RelayInfo

type RelayInfo struct {
	Online    *bool `json:"online"`
	Primary   bool  `json:"primary"`
	Disabled  bool  `json:"disabled"`
	Noredir   bool  `json:"noredir"`
	Listeners int   `json:"listeners"`
	Max       int   `json:"max"`
	Priority  int   `json:"priority"`
	Links     struct {
		Status string `json:"status"`
		Stream string `json:"stream"`
	} `json:"links"`
}

type RelayStatus

type RelayStatus struct {
	Relays    map[string]RelayInfo `json:"relays"`
	Listeners int                  `json:"listeners"`
	StreamURL string               `json:"stream_url"`
}

func FetchRelayStatus

func FetchRelayStatus(ctx context.Context, uri string) (RelayStatus, error)

FetchRelayStatus fetches the status page of the load balancer

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL