Esempio n. 1
0
func RegisterHandler(path string, handler http.HandlerFunc) {

	log.Write("Registering Handler", path, handler)

	http.HandleFunc(path, handler)

}
Esempio n. 2
0
func Start() {

	log.Write("ListenAndServe on :%n", port)

	log.Fatal(http.ListenAndServe(":"+port, nil))

}
Esempio n. 3
0
// Kick off a flow
func (f Flow) Run() {

	log.Write("Flow: Running ", f)

	f.steps[0].handle()

}
Esempio n. 4
0
// Handle a flow, assume http
func (fh FlowHandler) Handle(w http.ResponseWriter, r *http.Request) {

	log.Write("Handling", r, "Running", fh.F)

	go fh.F.Run()

}
Esempio n. 5
0
func RegisterFlow(p string, f *flow.Flow) {

	log.Write("Registering Flow", p, *f)

	fh := new(flow.FlowHandler)
	fh.F = *f

	http.HandleFunc(p, fh.Handle)

}
Esempio n. 6
0
// Create a new flow
func Create(n string) *Flow {

	f := new(Flow)
	f.name = n

	flows = append(flows, f)

	log.Write("Flow: create", n)

	return f

}
Esempio n. 7
0
func listen() {

	for {
		t := <-bus

		if t == killMessage {
			//			break
		}

		log.Write("Flow: heard", t)

		Trigger(t)
	}

}
Esempio n. 8
0
// Add a step to a flow
func (f *Flow) AddStep(n string, st string, et string, a func()) *step {

	s := new(step)
	s.name = n
	s.startTrigger = st
	s.endTrigger = et
	s.action = a

	f.steps = append(f.steps, s)

	log.Write("Step: create", *s, "in", *f)

	return s

}
Esempio n. 9
0
func Broadcast(m string) {

	log.Write("Flow: Broadcast", m)

	bus <- m
}