This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"strings" | |
) | |
var result []string | |
func main() { | |
permuteString("", "golang") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using EventTower; | |
using MessagesCommon; | |
using System; | |
using System.Threading.Tasks; | |
namespace Worker | |
{ | |
public class EventHandler | |
: IMessageHandler<MessagesCommon.CustomerEmailChanged> | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using EventTower; | |
using MessagesCommon; | |
namespace Sender | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
//defining endpoint named sender |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Threading.Tasks; | |
namespace EventTower | |
{ | |
public interface IMessageHandler<T> where T: IMessage | |
{ | |
Task Handle(T message); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void StartConsuming() | |
{ | |
consumerChannel = connection.CreateModel(); | |
consumerChannel.ExchangeDeclare(COMMAND_EXCHANGE_NAME, ExchangeType.Direct); | |
consumerChannel.ExchangeDeclare(EVENT_EXCHANGE_NAME, ExchangeType.Fanout); | |
var queue = consumerChannel.QueueDeclare(queue: queueName); | |
consumerChannel.QueueBind(queue, COMMAND_EXCHANGE_NAME, routingKey: queueName); | |
consumerChannel.QueueBind(queue, EVENT_EXCHANGE_NAME, routingKey: queueName); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void BasicPublish(IEvent @event) | |
{ | |
using(var channel = connection.CreateModel()) | |
{ | |
channel.ExchangeDeclare(EVENT_EXCHANGE_NAME, type: ExchangeType.Fanout); | |
channel.BasicPublish(exchange: EVENT_EXCHANGE_NAME, routingKey: string.Empty, basicProperties: null, body: @event.ToJson().ToByteArray()); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void BasicPublish(ICommand command, string destination) | |
{ | |
using (var channel = connection.CreateModel()) | |
{ | |
channel.ExchangeDeclare(COMMAND_EXCHANGE_NAME, type: ExchangeType.Direct); | |
channel.BasicPublish(exchange: COMMAND_EXCHANGE_NAME, routingKey: destination, basicProperties: null, body: command.ToJson().ToByteArray()); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void TryConnect() | |
{ | |
var policy = RetryPolicy.Handle<SocketException>().Or<BrokerUnreachableException>() | |
.WaitAndRetry(retryCount, op => TimeSpan.FromSeconds(Math.Pow(2, op)), (ex, time) => | |
{ | |
Console.WriteLine("Couldn't connect to RabbitMQ server..."); | |
}); | |
policy.Execute(() => | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Linq; | |
using System.Reflection; | |
using MessageBus.Exceptions; | |
using Newtonsoft.Json; | |
using EventTower.Utils; | |
namespace EventTower | |
{ | |
public class MessageBusEndpoint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Net.Sockets; | |
using Newtonsoft.Json; | |
using Polly; | |
using Polly.Retry; | |
using RabbitMQ.Client; | |
using RabbitMQ.Client.Events; | |
using RabbitMQ.Client.Exceptions; | |
using EventTower.Extensions; |
NewerOlder