FixAlchemy.Generator (FIXAlchemy v0.2.4)

View Source

Generates Elixir modules from FIX specification XML files.

Parses FIX spec XML and generates compiled Elixir modules with field mappings, message parsers with repeating group support, and data-field metadata.

A session whose message set is split across two dictionaries — a FIXT transport dictionary for the session layer and an application dictionary for the business layer — is generated from the pair as one module set, merged with FixAlchemy.SpecParser.merge/2.

Generated sources are build artifacts, written to a per-user cache directory (override with config :fix_alchemy, :generated_dir) and compiled at runtime — never into an application's lib/, so no mix project ever takes ownership of them. The cache key includes the mtime of every dictionary in the set and a hash of the generator's own code, so both dictionary edits and generator changes regenerate automatically. Modules already loaded in the VM are reused only when their compiled md5 matches the cache, which recompiles over any stale copy a host application may have loaded.

Usage

{:ok, modules} = FixAlchemy.Generator.generate("FIX44.xml")

alias FixAlchemy.Generated.Fix44.Messages
position_data = Messages.parse_position_report(keyword_list)

{:ok, modules} = FixAlchemy.Generator.generate({"FIXT1.1.xml", "FIX50SP2.xml"})

alias FixAlchemy.Generated.Fixt11Fix50Sp2.Messages
report = Messages.parse("8", fields)

Summary

Functions

Generate Elixir modules from one FIX dictionary, or from a dictionary pair.

Directory holding generated sources.

Name the module set and cache directory a dictionary set generates.

Types

spec_source()

@type spec_source() :: binary() | {binary(), binary()}

Functions

generate(source)

@spec generate(spec_source()) :: {:ok, [module()]} | {:error, term()}

Generate Elixir modules from one FIX dictionary, or from a dictionary pair.

A {transport, application} pair is merged before generation, the transport dictionary defining the session layer and the application dictionary the business layer. The generated modules are named after every dictionary in the set, so a FIXT1.1.xml and FIX50SP2.xml session and a FIX44.xml session never share modules.

Generation is cached per dictionary set; editing any dictionary in the set regenerates it.

Concurrent calls for the same dictionary set are serialized: one generates and the rest reuse the result.

Returns

  • {:ok, [module_names]} - List of generated module atoms
  • {:error, reason} - Generation failed

generated_dir()

@spec generated_dir() :: binary()

Directory holding generated sources.

Defaults to the per-user cache directory; override with config :fix_alchemy, :generated_dir.

spec_name(source)

@spec spec_name(spec_source()) :: binary()

Name the module set and cache directory a dictionary set generates.

Names are derived from the dictionary file names, joined for a pair, so {"FIXT1.1.xml", "FIX50SP2.xml"} is "fixt1_1_fix50_sp2" and its modules live under FixAlchemy.Generated.Fixt11Fix50Sp2.