forked from External/grumble
Check for server existance in ctlrpc.
This commit is contained in:
parent
c785c45166
commit
cfa9172e69
1 changed files with 22 additions and 4 deletions
26
ctlrpc.go
26
ctlrpc.go
|
|
@ -13,12 +13,22 @@ type ControlRPC struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start a server
|
// Start a server
|
||||||
func (c *ControlRPC) Start(in *int, out *int) os.Error {
|
func (c *ControlRPC) Start(Id int64, out *int) os.Error {
|
||||||
|
server, exists := servers[Id]
|
||||||
|
if !exists {
|
||||||
|
return os.NewError("no such server")
|
||||||
|
}
|
||||||
|
_ = server
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stop a server
|
// Stop a server
|
||||||
func (c *ControlRPC) Stop(in *int, out *int) os.Error {
|
func (c *ControlRPC) Stop(Id int64, out *int) os.Error {
|
||||||
|
server, exists := servers[Id]
|
||||||
|
if !exists {
|
||||||
|
return os.NewError("no such server")
|
||||||
|
}
|
||||||
|
_ = server
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -30,7 +40,11 @@ type ConfigValue struct {
|
||||||
|
|
||||||
// Set a config value
|
// Set a config value
|
||||||
func (c *ControlRPC) SetConfig(in *ConfigValue, out *ConfigValue) os.Error {
|
func (c *ControlRPC) SetConfig(in *ConfigValue, out *ConfigValue) os.Error {
|
||||||
servers[in.Id].cfg.Set(in.Key, in.Value)
|
server, exists := servers[in.Id]
|
||||||
|
if !exists {
|
||||||
|
return os.NewError("no such server")
|
||||||
|
}
|
||||||
|
server.cfg.Set(in.Key, in.Value)
|
||||||
out.Id = in.Id
|
out.Id = in.Id
|
||||||
out.Key = in.Key
|
out.Key = in.Key
|
||||||
out.Value = in.Value
|
out.Value = in.Value
|
||||||
|
|
@ -39,8 +53,12 @@ func (c *ControlRPC) SetConfig(in *ConfigValue, out *ConfigValue) os.Error {
|
||||||
|
|
||||||
// Get a config value
|
// Get a config value
|
||||||
func (c *ControlRPC) GetConfig(in *ConfigValue, out *ConfigValue) os.Error {
|
func (c *ControlRPC) GetConfig(in *ConfigValue, out *ConfigValue) os.Error {
|
||||||
|
server, exists := servers[in.Id]
|
||||||
|
if !exists {
|
||||||
|
return os.NewError("no such server")
|
||||||
|
}
|
||||||
out.Id = in.Id
|
out.Id = in.Id
|
||||||
out.Key = in.Key
|
out.Key = in.Key
|
||||||
out.Value = servers[in.Id].cfg.StringValue(in.Key)
|
out.Value = server.cfg.StringValue(in.Key)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue