Skip to content

Installing and Configuring

Rob Hruska edited this page Mar 6, 2016 · 26 revisions

Important

The documentation in this Wiki is for version 2.6.0, which is not yet released. Documentation for the current version (2.5.0) is in the master README.md.


Installation is fairly minimal - just grab Hudl.Mjolnir from nuget.org using your Package Manager GUI or Console.

Mjolnir needs you to specify a configuration provider. The ConfigurableValues 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 ships with a configuration provider implementation that can read configuration values from a file; set the provider on application startup (before you use any Commands):

using Hudl.Config;

//...

ConfigProvider.UseProvider(new FileConfigurationProvider(@"c:\path\to", "config-file.txt"));

Configuration file contents are just Key=Value pairs, e.g.:

mjolnir.foo.bar.baz=5000

See Configuration Keys for available timeout, bulkhead, breaker, and other keys.

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 »