Lightning.Adaptors.Seed (Lightning v2.19.0)

View Source

Populates the adaptor catalogue from a JSON snapshot file.

Summary

Functions

Populates the catalogue from a JSON snapshot file and returns the number of records written.

Functions

seed_from_file(path, opts \\ [])

@spec seed_from_file(
  Path.t(),
  keyword()
) :: {:ok, non_neg_integer()}

Populates the catalogue from a JSON snapshot file and returns the number of records written.

The file is a JSON array of adaptor records in the shape Lightning.Adaptors.Catalogue.upsert_adaptor/1 accepts, as written by mix lightning.adaptors.snapshot or mix lightning.adaptors.dump.

Once the transaction commits, broadcasts {:changed, name, source} for every name the seed touched, so each node's Lightning.Adaptors.Invalidator drops its now-stale cache entries. In replace: true mode that includes names the wipe removed.

Options:

  • :source - :npm (default) or :local
  • :replace - when true, deletes every existing row for the source first, in the same transaction as the upserts
  • :sup - supervisor instance whose topic the broadcasts go to, defaulting to Lightning.Adaptors.Config.default_instance/0