Roux.Test.RawGate (roux v0.2.2)

Copy Markdown View Source

Holds a race in Roux.Blob open: at the file operations a gate names, it runs an action after the operation completed and before the store sees its result. A check-then-act race in the store then happens on every run: the gate is the other process, acting between the check and the act.

The store's file operations are raw (Roux.Blob.IO), past the VM's file server, so this hangs on Roux.Blob.IO's hook rather than standing in for the server. Install it only in a VM of its own (:peer): while it is installed, every store operation of the VM goes through it.

A gate is a map:

  • :name — what uninstall/0 reports its action's result under;
  • :ops — the operations it watches (:read_file, :write_file, :read_file_info, :read_link_info, :chmod, :utime, :list_dir, :rename (named by its source), :delete, :make_dir, :del_dir, :make_link (named by the existing file), :hash_file);
  • :path — the path they name;
  • :prefix — true to watch every path under :path as well;
  • :nth — which of the watched operations it acts at (default 1);
  • :action — {module, function, args}, run once, in a process of its own that the operation waits for; its own operations pass by the gate, which has already acted.

Summary

Types

See the moduledoc.

Functions

Puts gates in front of the store's file operations.

Takes the gates away, and returns each one's action's result by name: :not_run for a gate whose operation never came.

Types

gate()

@type gate() :: %{
  :name => term(),
  :ops => [atom()],
  :path => Path.t(),
  :action => {module(), atom(), [term()]},
  optional(:prefix) => boolean(),
  optional(:nth) => pos_integer()
}

See the moduledoc.

Functions

install(gates)

@spec install([gate()]) :: :ok

Puts gates in front of the store's file operations.

uninstall()

@spec uninstall() :: %{required(term()) => term()}

Takes the gates away, and returns each one's action's result by name: :not_run for a gate whose operation never came.