From 35afb346cb733d27c4ba53bc5659dc8050217f5a Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Wed, 20 Nov 2013 12:46:56 -0600 Subject: [PATCH] Add circuit basics. --- commands/pilosa-spawn/spawn.go | 21 +++++++++++++++++++++ commands/pilosa-worker/worker.go | 8 ++++++++ cruncher/cruncher.go | 12 ++++++++++++ 3 files changed, 41 insertions(+) create mode 100644 commands/pilosa-spawn/spawn.go create mode 100644 commands/pilosa-worker/worker.go diff --git a/commands/pilosa-spawn/spawn.go b/commands/pilosa-spawn/spawn.go new file mode 100644 index 000000000..670ee59ee --- /dev/null +++ b/commands/pilosa-spawn/spawn.go @@ -0,0 +1,21 @@ +package main + +import ( + _ "circuit/load/cmd" + "circuit/use/circuit" + "pilosa/cruncher" + "log" +) + +func main() { + log.Println("Spawning...") + + retrn, addr, err := circuit.Spawn("localhost", []string{"/cruncher"}, cruncher.App{}) + if err != nil { + log.Fatal(err) + } + log.Println(retrn, addr) + + circuit.Hang() +} + diff --git a/commands/pilosa-worker/worker.go b/commands/pilosa-worker/worker.go new file mode 100644 index 000000000..946f5f869 --- /dev/null +++ b/commands/pilosa-worker/worker.go @@ -0,0 +1,8 @@ +package main + +import ( + _ "circuit/load/worker" + _ "pilosa/cruncher" +) + +func main() {} diff --git a/cruncher/cruncher.go b/cruncher/cruncher.go index 309a22a48..8c93f79ed 100644 --- a/cruncher/cruncher.go +++ b/cruncher/cruncher.go @@ -4,6 +4,8 @@ import ( "pilosa/core" "pilosa/db" "log" + "circuit/use/circuit" + "time" ) type Cruncher struct { @@ -53,3 +55,13 @@ func (c *Cruncher) HandleInbox() { } } } + +type App struct{} +func (App) Main() { + log.Println("Starting cruncher!") + time.Sleep(60*time.Second) +} + +func init() { + circuit.RegisterFunc(App{}) +}