Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ale
autoradio
Commits
2bea900a
Commit
2bea900a
authored
Oct 15, 2015
by
ale
Browse files
do not export internal types
parent
f34c9e51
Changes
6
Hide whitespace changes
Inline
Side-by-side
node/doc.go
View file @
2bea900a
// 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).
//
...
...
node/icecast.go
View file @
2bea900a
...
...
@@ -47,21 +47,21 @@ type icecastStatusUnparsed struct {
Mounts
[]
icecastMountStatusUnparsed
`xml:"mount"`
}
type
I
cecastStatus
struct
{
type
i
cecastStatus
struct
{
Mounts
[]
autoradio
.
IcecastMountStatus
Up
bool
}
type
icecastController
struct
{
config
*
icecastConfig
status
*
I
cecastStatus
status
*
i
cecastStatus
stop
chan
bool
}
func
N
ewIcecastController
(
publicI
p
string
,
maxClients
int
)
*
icecastController
{
func
n
ewIcecastController
(
publicI
P
string
,
maxClients
int
)
*
icecastController
{
return
&
icecastController
{
config
:
newIcecastConfig
(
publicI
p
,
maxClients
),
status
:
&
I
cecastStatus
{},
config
:
newIcecastConfig
(
publicI
P
,
maxClients
),
status
:
&
i
cecastStatus
{},
}
}
...
...
@@ -138,13 +138,13 @@ func (ic *icecastController) Update(conf *clusterConfig, isMaster bool, masterAd
return
nil
}
func
(
ic
*
icecastController
)
GetStatus
()
*
I
cecastStatus
{
func
(
ic
*
icecastController
)
GetStatus
()
*
i
cecastStatus
{
return
ic
.
status
}
func
(
ic
*
icecastController
)
Run
(
stop
chan
bool
)
{
t
:=
time
.
NewTicker
(
3
*
time
.
Second
)
downStatus
:=
&
I
cecastStatus
{}
downStatus
:=
&
i
cecastStatus
{}
for
{
select
{
case
<-
t
.
C
:
...
...
@@ -162,7 +162,7 @@ func (ic *icecastController) Run(stop chan bool) {
}
}
func
(
ic
*
icecastController
)
fetchStatus
()
(
*
I
cecastStatus
,
error
)
{
func
(
ic
*
icecastController
)
fetchStatus
()
(
*
i
cecastStatus
,
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
)
(
*
I
cecastStatus
,
error
)
{
func
(
ic
*
icecastController
)
parseStatusPage
(
input
io
.
Reader
)
(
*
i
cecastStatus
,
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
:=
I
cecastStatus
{
status
:=
i
cecastStatus
{
Up
:
true
,
Mounts
:
make
([]
autoradio
.
IcecastMountStatus
,
0
,
len
(
ustatus
.
Mounts
)),
}
...
...
node/icecast_config.go
View file @
2bea900a
...
...
@@ -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
(
publicI
p
string
,
maxClients
int
)
*
icecastConfig
{
func
newIcecastConfig
(
publicI
P
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
:
publicI
p
,
Hostname
:
publicI
P
,
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
(
i
c
*
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
}
}
i
c
.
Mounts
=
mounts
i
c
.
Relays
=
relays
c
.
Mounts
=
mounts
c
.
Relays
=
relays
}
node/icecast_test.go
View file @
2bea900a
...
...
@@ -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
:=
N
ewIcecastController
(
"1.2.3.4"
,
1000
)
ic
:=
n
ewIcecastController
(
"1.2.3.4"
,
1000
)
result
,
err
:=
ic
.
parseStatusPage
(
strings
.
NewReader
(
xml
))
if
err
!=
nil
{
t
.
Fatal
(
err
)
...
...
node/node.go
View file @
2bea900a
...
...
@@ -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
()
*
I
cecastStatus
GetStatus
()
*
i
cecastStatus
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
:
N
ewIcecastController
(
name
,
maxListeners
*
2
),
icecast
:
n
ewIcecastController
(
name
,
maxListeners
*
2
),
transcoderFn
:
func
(
p
*
liquidsoapParams
)
(
transcodingController
,
error
)
{
return
newLiquidsoap
(
p
)
},
...
...
node/node_test.go
View file @
2bea900a
...
...
@@ -30,8 +30,8 @@ func (m *mockController) Update(conf *clusterConfig, isMaster bool, masterAddr n
return
nil
}
func
(
m
*
mockController
)
GetStatus
()
*
I
cecastStatus
{
return
&
I
cecastStatus
{
Up
:
true
}
func
(
m
*
mockController
)
GetStatus
()
*
i
cecastStatus
{
return
&
i
cecastStatus
{
Up
:
true
}
}
type
mockTranscoder
struct
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment