manager

package
v0.0.0-...-e61f6d1 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2025 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GUEST_PASSWORD_LENGTH  = 20
	GUEST_EXPIRE_LOOP_TICK = time.Minute * 5
	GUEST_THREAD_LIMIT     = 3
	GUEST_KILL_LIMIT       = 3
)
View Source
const (
	TUNEIN_PARTNER_ID  = "partnerId"
	TUNEIN_PARTNER_KEY = "partnerKey"
	TUNEIN_STATION_ID  = "id"
)

Variables

This section is empty.

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 NewGRPCServer

func NewGRPCServer(ctx context.Context, m *Manager, g *GuestService) (*grpc.Server, error)

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

Types

type Guest

type Guest struct {
	Nick GuestNick

	User *radio.User
	// AuthTime is the time this guest got authorized
	AuthTime time.Time

	// HasStreamed indicates if this guest has been "live" on the stream
	HasStreamed bool
	// ThreadSets is the amount of times this guest has used their .thread privilege
	ThreadSets int
	// KillAttempts is the amount of times this guest has used their .kill privilege
	KillAttempts int
}

type GuestNick

type GuestNick = string

type GuestService

type GuestService struct {
	Authorized map[GuestNick]*Guest
	// contains filtered or unexported fields
}

func (*GuestService) Auth

func (gs *GuestService) Auth(ctx context.Context, nick GuestNick) (*radio.User, error)

AddGuest adds the nick given as a guest user

func (*GuestService) CanDo

func (gs *GuestService) CanDo(ctx context.Context, nick GuestNick, action radio.GuestAction) (ok bool, err error)

func (*GuestService) Create

func (gs *GuestService) Create(ctx context.Context, nick GuestNick) (*radio.User, string, error)

func (*GuestService) Deauth

func (gs *GuestService) Deauth(ctx context.Context, nick GuestNick) error

func (*GuestService) Do

func (gs *GuestService) Do(ctx context.Context, nick GuestNick, action radio.GuestAction) (ok bool, err error)

type Manager

type Manager struct {
	Storage radio.StorageService
	// contains filtered or unexported fields
}

Manager manages shared state between different processes

func NewManager

func NewManager(ctx context.Context, store radio.StorageService, prober audio.Prober, state []byte) (*Manager, error)

NewManager returns a manager ready for use

func (*Manager) CloseSubs

func (m *Manager) CloseSubs()

CloseSubs calls CloseSubs on all internal manager streams

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) Shutdown

func (m *Manager) Shutdown()

Shutdown calls Shutdown on all internal manager streams

func (*Manager) Status

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

Status returns the current status of the radio

func (*Manager) UpdateFromStorage

func (m *Manager) UpdateFromStorage(ctx context.Context) error

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, su *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 TuneinUpdater

type TuneinUpdater struct {
	// contains filtered or unexported fields
}

func NewTuneinUpdater

func NewTuneinUpdater(ctx context.Context, cfg config.Config, manager radio.ManagerService, client *http.Client) (*TuneinUpdater, error)

func (*TuneinUpdater) Close

func (tu *TuneinUpdater) Close() error

func (*TuneinUpdater) Update

func (tu *TuneinUpdater) Update(ctx context.Context, metadata string) error

Update tries to update the tunein api by using the api endpoint documented at https://tunein.com/broadcasters/api/

Jump to

Keyboard shortcuts

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