Renaming some stuff and starting on ch. 4 rpc example implemented in Go

This commit is contained in:
Dan Buch 2012-12-01 19:06:23 -05:00
parent 4c63923238
commit b0553c1b8d
7 changed files with 64 additions and 11 deletions

View File

@ -1,8 +1,9 @@
REPO_BASE := github.com/meatballhat/box-o-sand/sylvilagus/go
PACKAGES := \
$(REPO_BASE)/sylvilagus-conntest \
$(REPO_BASE)/sylvilagus-chapter02-hello-world-consumer \
$(REPO_BASE)/sylvilagus-chapter02-hello-world-producer
$(REPO_BASE)/sylvilagus-ch02-hello-world-consumer \
$(REPO_BASE)/sylvilagus-ch02-hello-world-producer \
$(REPO_BASE)/sylvilagus-ch04-rpc-server
test: build
go test -x -v $(PACKAGES)

View File

@ -0,0 +1,14 @@
package main
import (
"log"
)
import (
"github.com/meatballhat/box-o-sand/sylvilagus/go/sylvilagus"
)
func main() {
log.Println("Would be using AMQP_URI =", sylvilagus.AMQP_URI)
log.Println("OH HAI RPC")
}

View File

@ -2,21 +2,12 @@ package sylvilagus
import (
"log"
"os"
)
import (
"github.com/streadway/amqp"
)
var AMQP_URI = os.Getenv("SYLVILAGUS_AMQP_URI")
func init() {
if len(AMQP_URI) < 1 {
log.Fatal("SYLVILAGUS_AMQP_URI is not defined!")
}
}
func CreateHelloTopology(connection *amqp.Connection) (*amqp.Channel, error) {
channel, err := connection.Channel()
if err != nil {

View File

@ -0,0 +1,33 @@
package sylvilagus
import (
"log"
)
import (
"github.com/streadway/amqp"
)
func CreateRPCTopology(connection *amqp.Connection) (channel *amqp.Channel, err error) {
if channel, err = connection.Channel(); err != nil {
log.Println("Failed to get channel!: ", err)
return nil, err
}
if err = channel.ExchangeDeclare("rpc", "direct", true, false, false, false, nil); err != nil {
log.Println("Failed to declare exchange!: ", err)
return nil, err
}
if _, err = channel.QueueDeclare("ping", false, false, false, false, nil); err != nil {
log.Println("Failed to declare queue!: ", err)
return nil, err
}
if err = channel.QueueBind("ping", "ping", "rpc", false, nil); err != nil {
log.Println("Failed to bind to queue!: ", err)
return nil, err
}
return channel, nil
}

View File

@ -0,0 +1,14 @@
package sylvilagus
import (
"log"
"os"
)
var AMQP_URI = os.Getenv("SYLVILAGUS_AMQP_URI")
func init() {
if len(AMQP_URI) < 1 {
log.Fatal("SYLVILAGUS_AMQP_URI is not defined!")
}
}