Archiving a bunch of old stuff
This commit is contained in:
37
oldstuff/sylvilagus/go/sylvilagus/hello.go
Normal file
37
oldstuff/sylvilagus/go/sylvilagus/hello.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package sylvilagus
|
||||
|
||||
import (
|
||||
"log"
|
||||
)
|
||||
|
||||
import (
|
||||
"github.com/streadway/amqp"
|
||||
)
|
||||
|
||||
func CreateHelloTopology(connection *amqp.Connection) (*amqp.Channel, error) {
|
||||
channel, err := connection.Channel()
|
||||
if err != nil {
|
||||
log.Println("Failed to get channel!: ", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = channel.ExchangeDeclare("hello-exchange", "direct", true, false, false, false, nil)
|
||||
if err != nil {
|
||||
log.Println("Failed to declare exchange!: ", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
_, err = channel.QueueDeclare("hello-queue", false, false, false, false, nil)
|
||||
if err != nil {
|
||||
log.Println("Failed to declare queue!: ", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = channel.QueueBind("hello-queue", "hola", "hello-exchange", false, nil)
|
||||
if err != nil {
|
||||
log.Println("Failed to bind to queue!: ", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return channel, nil
|
||||
}
|
39
oldstuff/sylvilagus/go/sylvilagus/rpc.go
Normal file
39
oldstuff/sylvilagus/go/sylvilagus/rpc.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package sylvilagus
|
||||
|
||||
import (
|
||||
"log"
|
||||
"time"
|
||||
)
|
||||
|
||||
import (
|
||||
"github.com/streadway/amqp"
|
||||
)
|
||||
|
||||
type Ping struct {
|
||||
ClientName string `json:"client_name"`
|
||||
Time time.Time `json:"time"`
|
||||
}
|
||||
|
||||
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
|
||||
}
|
14
oldstuff/sylvilagus/go/sylvilagus/uri.go
Normal file
14
oldstuff/sylvilagus/go/sylvilagus/uri.go
Normal 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!")
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user