1
0
mirror of synced 2024-11-16 06:43:51 +00:00

Wrote some more documentation

This commit is contained in:
Mark van Renswoude 2017-02-11 21:32:30 +01:00
parent 9578a3efaa
commit 8126549841
5 changed files with 128 additions and 5 deletions

View File

@ -155,4 +155,4 @@ texinfo_documents = [
]
highlight_language = 'csharp'

11
docs/flow.rst Normal file
View File

@ -0,0 +1,11 @@
Flow
====
.. error:: You've stumbled upon a piece of unfinished documentation.
Behind you is all prior knowledge. In front of you is nothing but emptyness. What do you do?
1. Attempt to explore further
2. Complain to the author and demand your money back
3. Abandon all hope
> |

View File

@ -13,6 +13,55 @@ You will need an integration package as well for your IoC (Inversion of Control)
Configuring Tapeti
------------------
First create an instance of TapetiConfig, tell it which controllers to register and have it gather all the information by calling Build. Then pass the result to a TapetiConnection.
::
using SimpleInjector;
using Tapeti;
internal class Program
{
private static void Main()
{
var container = new Container();
var config = new TapetiConfig(new SimpleInjectorDependencyResolver(container))
.RegisterAllControllers()
.Build();
using (var connection = new TapetiConnection(config)
{
Params = new TapetiConnectionParams
{
Host = "localhost"
}
})
{
connection.SubscribeSync();
// Start service
}
}
}
.. note:: RegisterAllControllers without parameters searches the entry assembly. Pass an Assembly parameter to register other or additional controllers.
.. caution:: Tapeti attempts to register it's default implementations in the IoC container during configuration, as well as when starting the connection (to register IPublisher). If your container is immutable after the initial configuration, like SimpleInjector is, make sure that you run the Tapeti configuration before requesting any instances from the container.
Defining a message
------------------
A message is a plain object which can be serialized using `Json.NET <http://www.newtonsoft.com/json>`_.
::
public class SomethingHappenedMessage
{
public string Description { get; set; }
}
Creating a message controller
-----------------------------
.. error:: You've stumbled upon a piece of unfinished documentation.
Behind you is all prior knowledge. In front of you is nothing but emptyness. What do you do?
@ -21,5 +70,3 @@ Configuring Tapeti
3. Abandon all hope
> |
.. caution:: Tapeti attempts to register it's default implementations in the IoC container during configuration, as well as when starting the connection (to register IPublisher). If your container is immutable after the initial configuration, like SimpleInjector is, make sure that you run the Tapeti configuration before requesting any instances from the container.

63
docs/indepth.rst Normal file
View File

@ -0,0 +1,63 @@
In-depth
========
Messages
--------
As described in the Getting started guide, a message is a plain object which can be serialized using `Json.NET <http://www.newtonsoft.com/json>`_.
When communicating between services it is considered best practice to define messages in separate class library assemblies which can be referenced in other services. This establishes a public interface between services and components without binding to the implementation.
Routing keys
------------
The routing key is determined by converting CamelCase to dot-separated lowercase, leaving out "Message" at the end if it is present. In the example below, the routing key will be "something.happened":
::
public class SomethingHappenedMessage
{
public string Description { get; set; }
}
This behaviour is implemented using the IRoutingKeyStrategy interface. For more information about changing this, see `Overriding default behaviour`_
Exchanges
---------
The exchange on which the message is published and consumers are expected to bind to is determined by the first part of the namespace, skipping "Messaging" if it is present. In the example below, the exchange will be "Example":
::
namespace Messaging.Example.Events
{
public class SomethingHappenedMessage
{
public string Description { get; set; }
}
}
This behaviour is implemented using the IExchangeStrategy interface. For more information about changing this, see `Overriding default behaviour`_
Overriding default behaviour
----------------------------
Various behaviours of Tapeti are implemented using interfaces which are resolved using the IoC container. Tapeti will attempt to register the default implementations, but these can easily be replaced with your own version. For example:
::
// Nod to jsforcats.com
public class YellItRoutingKeyStrategy : IRoutingKeyStrategy
{
public string GetRoutingKey(Type messageType)
{
return messageType.Name.ToUpper() + "!!!!";
}
}
container.Register<IRoutingKeyStrategy, YellItRoutingKeyStrategy>();
The best place to register your implementation is before calling TapetiConfig.

View File

@ -7,3 +7,5 @@ Tapeti documentation
introduction
gettingstarted
indepth
flow