-
Notifications
You must be signed in to change notification settings - Fork 0
Installing and Configuring
Installation is fairly minimal - just grab Hudl.Mjolnir from nuget.org using your Package Manager GUI or Console.
Mjolnir needs you to instantiate a MjolnirConfiguration
file with correct values. The MjolnirConfiguration
s within the app all have sensible defaults, but you'll want to adjust them after observing how your application behaves.
Mjolnir expects an instance of MjolnirConfiguration class to be provided. Values in this class configure behavior of the library.
We have provided a sample implementation of configuration provider which will read configuration from a JSON file and reloads configuration when there have been any changes to that file. See ExampleJsonConfigProvider.
Sample JSON file can be found here
See Configuration for available timeout, bulkhead, breaker, and other configurations.
If you don't set a configuration provider, default values (defined in the code) will be used for everything in Mjolnir (which isn't ideal, because you'll want to tune components and commands for your application).
You can also inject a metrics implementation to capture events of importance. We use Riemann, but other clients (e.g. statsd) should work well, also. The following events are fired:
- CommandInvoked
- EnterBulkhead
- LeaveBulkhead
- RejectedByBulkhead
- BulkheadGauge
- BreakerTripped
- BreakerFixed
- RejectedByBreaker
- BreakerSuccessCount
- BreakerFailureCount
- BreakerGauge
More details are available in the doc comments for IMetricEvents
.
You'll need to implement Hudl.Mjolnir.External.IMetricEvents
and pass it into CommandInvoker creation.
using Hudl.Mjolnir;
using Hudl.Mjolnir.External;
IMetricEvents metricEvents = new MyImplementationOfMetricEvents(/* ... */);
//...
var commandInvoker = new CommandInvoker(
mjolnirConfiguration,
logFactory,
metricEvents,
breakerExceptionHandler,
bulkheadInvoker)
Use only one instance of command invoker per application. Ideally use Dependency Injection for that.
« When to Use • Commands »