Commit 2bea900a authored by ale's avatar ale

do not export internal types

parent f34c9e51
// The 'node' supervisor is the daemon that controls the Icecast
// Package node implements the Icecast node supervisor.
//
// The node supervisor is the daemon that controls the Icecast
// server, updating its configuration according to what is stored in
// the distributed database (etcd).
//
......
......@@ -47,21 +47,21 @@ type icecastStatusUnparsed struct {
Mounts []icecastMountStatusUnparsed `xml:"mount"`
}
type IcecastStatus struct {
type icecastStatus struct {
Mounts []autoradio.IcecastMountStatus
Up bool
}
type icecastController struct {
config *icecastConfig
status *IcecastStatus
status *icecastStatus
stop chan bool
}
func NewIcecastController(publicIp string, maxClients int) *icecastController {
func newIcecastController(publicIP string, maxClients int) *icecastController {
return &icecastController{
config: newIcecastConfig(publicIp, maxClients),
status: &IcecastStatus{},
config: newIcecastConfig(publicIP, maxClients),
status: &icecastStatus{},
}
}
......@@ -138,13 +138,13 @@ func (ic *icecastController) Update(conf *clusterConfig, isMaster bool, masterAd
return nil
}
func (ic *icecastController) GetStatus() *IcecastStatus {
func (ic *icecastController) GetStatus() *icecastStatus {
return ic.status
}
func (ic *icecastController) Run(stop chan bool) {
t := time.NewTicker(3 * time.Second)
downStatus := &IcecastStatus{}
downStatus := &icecastStatus{}
for {
select {
case <-t.C:
......@@ -162,7 +162,7 @@ func (ic *icecastController) Run(stop chan bool) {
}
}
func (ic *icecastController) fetchStatus() (*IcecastStatus, error) {
func (ic *icecastController) fetchStatus() (*icecastStatus, error) {
resp, err := http.Get(fmt.Sprintf("http://localhost:%d%s", autoradio.IcecastPort, statusPage))
if err != nil {
return nil, err
......@@ -171,7 +171,7 @@ func (ic *icecastController) fetchStatus() (*IcecastStatus, error) {
return ic.parseStatusPage(resp.Body)
}
func (ic *icecastController) parseStatusPage(input io.Reader) (*IcecastStatus, error) {
func (ic *icecastController) parseStatusPage(input io.Reader) (*icecastStatus, error) {
var ustatus icecastStatusUnparsed
if err := xml.NewDecoder(input).Decode(&ustatus); err != nil {
return nil, err
......@@ -191,7 +191,7 @@ func (ic *icecastController) parseStatusPage(input io.Reader) (*IcecastStatus, e
return 0
}
status := IcecastStatus{
status := icecastStatus{
Up: true,
Mounts: make([]autoradio.IcecastMountStatus, 0, len(ustatus.Mounts)),
}
......
......@@ -136,7 +136,7 @@ type icecastConfig struct {
// to a file for persistence. It is not really meant to be used by the
// operator.
//
func newIcecastConfig(publicIp string, maxClients int) *icecastConfig {
func newIcecastConfig(publicIP string, maxClients int) *icecastConfig {
// We don't use the global source password, but icecast is
// happier if it's set, so we just use a random password every
// time.
......@@ -159,7 +159,7 @@ func newIcecastConfig(publicIp string, maxClients int) *icecastConfig {
AdminUser: "admin",
AdminPassword: adminPw,
},
Hostname: publicIp,
Hostname: publicIP,
Fileserve: 1,
Paths: icePathsConfig{
Basedir: "/usr/share/icecast2",
......@@ -270,7 +270,7 @@ func (l mountList) Less(i, j int) bool {
// masterelection state. This will clear the Mounts and Relays fields
// and set them to new values. The mounts are sorted by name so that
// the XML representation generated by Encode() is consistent.
func (ic *icecastConfig) Update(config *clusterConfig, isMaster bool, masterAddr string) {
func (c *icecastConfig) Update(config *clusterConfig, isMaster bool, masterAddr string) {
var mounts []iceMountConfig
var relays []iceRelayConfig
......@@ -290,6 +290,6 @@ func (ic *icecastConfig) Update(config *clusterConfig, isMaster bool, masterAddr
}
}
ic.Mounts = mounts
ic.Relays = relays
c.Mounts = mounts
c.Relays = relays
}
......@@ -9,7 +9,7 @@ func TestIcecast_TestParseStatusPage(t *testing.T) {
xml := `<?xml version="1.0"?>
<status><mount name="/test.ogg"><listeners>3</listeners><bitrate/><quality/><video-quality/><frame-size/><frame-rate/></mount></status>`
ic := NewIcecastController("1.2.3.4", 1000)
ic := newIcecastController("1.2.3.4", 1000)
result, err := ic.parseStatusPage(strings.NewReader(xml))
if err != nil {
t.Fatal(err)
......
......@@ -134,7 +134,7 @@ func (c *configWatcher) Delete(key string) {
// replace real processes with mocks while testing.
type controller interface {
Update(*clusterConfig, bool, net.IP) error
GetStatus() *IcecastStatus
GetStatus() *icecastStatus
Run(chan bool)
}
......@@ -229,7 +229,7 @@ func NewRadioNode(name string, ips []net.IP, netDev string, bwLimit float64, max
uint64(*masterElectionTTL),
mech),
syncer: newConfigWatcher(client, config, upch),
icecast: NewIcecastController(name, maxListeners*2),
icecast: newIcecastController(name, maxListeners*2),
transcoderFn: func(p *liquidsoapParams) (transcodingController, error) {
return newLiquidsoap(p)
},
......
......@@ -30,8 +30,8 @@ func (m *mockController) Update(conf *clusterConfig, isMaster bool, masterAddr n
return nil
}
func (m *mockController) GetStatus() *IcecastStatus {
return &IcecastStatus{Up: true}
func (m *mockController) GetStatus() *icecastStatus {
return &icecastStatus{Up: true}
}
type mockTranscoder struct {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment