Skip to content

Installing and Configuring

Damian Turczynski edited this page Oct 25, 2017 · 2 revisions

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 MjolnirConfigurations within the app all have sensible defaults, but you'll want to adjust them after observing how your application behaves.

Initializing the Default File Configuration Provider

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).

Hooking into Metric Events

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 UseCommands »