This is a test!
Let's play a little bit :)
What about some gist?
And this should be colorized:
function() {
colorMePlease();
}
And some PHP:
<?php
$args = bson_decode(base64_decode($argv[1]));
$out = "Spawned with args " . print_r($args, 1);
sleep(5);
print base64_encode(bson_encode(array('output' => $out)));
flush();
exit(0);
What about some Golang?
package cage
import (
"github.com/streadway/amqp"
)
type Queue struct {
AmqpConnection amqp.Connection
Channel *amqp.Channel
InQueue amqp.Queue
OutQueue amqp.Queue
In <-chan amqp.Delivery
Out chan *ResultPayload
}
type ResultPayload struct {
CorrelationId string
Output string
}
type AmqpConnection func(string) (*amqp.Connection, error)
func (q *Queue) Init(bindingKey string, amqpDial AmqpConnection) {
conn, err := amqpDial("amqp://guest:guest@localhost:5672/")
//conn, err := AmqpConnect()
if err != nil {
failOnError(err, "Failed to connect to RabbitMQ")
defer conn.Close()
}
q.Channel, err = conn.Channel()
if err != nil {
failOnError(err, "Failed to open a channel")
defer q.Channel.Close()
}
err = q.Channel.ExchangeDeclare(
"cage_exchange", // name
"direct", // kind
false, // durable
false, // auto delete
false, // internal
false, // no wait
nil, // arguments
)
if err != nil {
failOnError(err, "Failed during Exchange declaration")
defer q.Channel.Close()
}
q.InQueue, err = q.Channel.QueueDeclare(
"", // name,
false, // durable,
false, // delete when unusued,
false, // exclusive,
false, // noWait,
nil, // arguments
)
q.Channel.QueueBind(
q.InQueue.Name, // name
bindingKey, // binding key
"cage_exchange", // exchange
false, // no wait
nil, // arguments
)
q.OutQueue, err = q.Channel.QueueDeclare(
"Services." + bindingKey + ".OUT", // name,
false, // durable,
false, // delete when unusued,
false, // exclusive,
false, // noWait,
nil, // arguments
)
q.In, err = q.Channel.Consume(q.InQueue.Name, "", false, false, false, false, nil)
if err != nil {
failOnError(err, "Failed to register a consumer")
}
q.Out = make(chan *ResultPayload)
}