broken: warrend: moving to unified messeging system

This commit is contained in:
Dan Ballard 2015-03-29 10:45:43 -07:00
parent cc859d1780
commit c3c6bee7a8
4 changed files with 51 additions and 11 deletions

1
.gitignore vendored
View File

@ -3,3 +3,4 @@
/deploy
/cmd/warren/warren
/cmd/warrend/warrend
.project

View File

@ -71,13 +71,12 @@ func unregRun(cmd *SockCommand, c net.Conn, path string, args ...string) {
}
err := conf.RmDeployment(args[0])
if err != nil {
warren.WriteStringz(c, "ERROR: " + err.Error())
return
}
warren.WriteStringz(c, "Unregistered deployment " + args[0])
}
// Assume nick, check if registered
deps := conf.GetConf().Deployments
arg := args[0]
if _,ok := deps[arg]; !ok {
// not a registered nick, try as path
absPath := absPath(path, arg)
if _,ok := conf.
}
}

View File

@ -8,6 +8,29 @@ import (
"os"
)
type MsgType int
const (
AddDeployment MsgType = iota
RmDeploymen
)
type Msg struct {
mType MsgType
reply chan error
args map[string]string
}
func NewMsg(mType MsgType, args map[string]string) *Msg {
var m = &Msg{mType, make(chan error), args}
return m
}
func (m *Msg) Call() error {
confChan <- *m
err := <-m.reply
return err
}
// Conf package - thread safe conf
// All write ops are public API functions
// that internall use channels to thread safely queue writes
@ -22,7 +45,8 @@ type Conf struct {
var conf *Conf = nil
var Init = make(chan bool)
var addDeploymentChan = make(chan DeploymentMsg)
var confChan = make(chan Msg)
func loadConf() {
file, err := os.Open(warren.WarrendConf)
@ -82,7 +106,9 @@ func Run() {
Init <- true
// loop for Writes
for {
select {
m := <- confChan
select (m.mType) {
case dm := <-addDeploymentChan:
addDeployment(&dm)
}

View File

@ -60,3 +60,17 @@ func AddDeployment(d *DeploymentMsg) error {
return nil
}
func RmDeployment(string arg) error {
reply = make(chan error)
rmDeploymentChan <-
// Assume nick, check if registered
deps := GetConf().Deployments
arg := args[0]
if _,ok := deps[arg]; !ok {
// not a registered nick, try as path
absPath := absPath(path, arg)
// if _,ok := conf.
}
}