Skip to content

Installing and Configuring

Damian Turczynski edited this page Oct 24, 2017 · 26 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
  • BulkheadConfigGauge
  • BreakerTripped
  • BreakerFixed
  • RejectedByBreaker
  • BreakerSuccessCount
  • BreakerFailureCount
  • BreakerConfigGauge

More details are available in the doc comments for IMetricEvents.

You'll need to implement Hudl.Mjolnir.External.IMetricEvents and set it on CommandContext.

using Hudl.Mjolnir;
using Hudl.Mjolnir.External;

//...

CommandContext.MetricEvents = new MyMetricsHandler();

Set CommandContext.MetricEvents early on application startup; breakers and bulkheads will cache their metrics implementations, and won't pick up a new one if you set it after they've been created.

SmartThreadPool dependency

Mjolnir uses SmartThreadPool, but has to package and reference it directly. See Issue #16.


« When to UseCommands »