Skip to content

v0.3.0

Choose a tag to compare

@msz msz released this 21 Oct 23:36
· 137 commits to master since this release

The biggest release yet!

Huge speed improvements

[#53]

Hammox v0.2 and below was completely stateless. Any time a Hammox-protected function was called, types needed to be read from disk and parsed from the compiled binary files. This created a huge bottleneck which given complex typespecs with many types slowed down Hammox-heavy test suites considerably.

Hammox v0.3 includes a typespec cache server and keeps all types in memory once first read from disk. Now the performance impact is practically indistinguishable from Mox.

Interface simplifications and shortcuts

Decorate all functions designated by a behaviour by default

[#54] [#55]

When using the "batch" version of protect where you pass an implementation module, a behaviour module, and a list of functions, the list of functions is now optional. Hammox will decorate all functions from the behaviour by default.

Example:

defmodule Calculator do
  @callback add(integer(), integer()) :: integer()
end

defmodule TestCalculator do
  def add(a, b), do: a + b
end

# Hammox v0.2
Hammox.protect(TestCalculator, Calculator, add: 2)

# Hammox v0.3
Hammox.protect(TestCalculator, Calculator)

Shortcuts for behaviour-implementation modules

[#51] [#62]

When using modules which contain both callbacks and implementations, you now only need to pass the module to protect once.

Example:

defmodule Calculator do
  @callback add(integer(), integer()) :: integer()
  def add(a, b), do: a + b
end

# Hammox v0.2
Hammox.protect(Calculator, Calculator, add: 2)

# Hammox v0.3
Hammox.protect(Calculator, add: 2)

Better exceptions for protect edge cases

[#52]

Before, passing nonexistent module to protect resulted in an ugly internal exception. Now, we raise a better exception explaning what happened.

Type checking for stubs

[#58]

Before, calls to stubs created by Hammox were not being type checked. This was an oversight. In Hammox v0.3, calls to stubs created by Hammox using Hammox.stub/3 are type checked.

Mox update

[#50]

Hammox v0.3 now includes Mox 1.0.0.

Acknlowledgements

Thanks to @saneery, @randycoulman, @jotaviobiondo and @SophisticaSean for helping make this release happen!