View Source Mobius.Bundle (mobius v0.3.7)

Link to this section Summary

Types

Options to use when extracting

Meta information for a bundle

Options for creating a bundle

t()

A bundle

The target is who the the bundle is created for

Link to this section Types

Specs

extract_opt() :: {:time_as, module()} | {:extract_dir, Path.t()}

Options to use when extracting

  • :time_as - convert the system time into either DateTime or NaiveDateTime.
  • :extract_dir - the directory to use for bundle extraction, this is cleaned up after extraction.

Converting time is useful because different time series databases expect different types of timestamps. If you're saving data into a time series database be sure to read the documentation to make sure you're providing the right information to your database.

Specs

meta() :: %{
  target: target(),
  version: non_neg_integer(),
  number_of_records: non_neg_integer()
}

Meta information for a bundle

  • :target - the target name of the device or application using mobius
  • :version - the bundle version used when creating the bundle
  • :number_of_records - the number of records in the bundle

Specs

save_opt() ::
  {:out_dir, binary()}
  | {:prefix, binary() | integer()}
  | :compressed
  | :verbose

Options for creating a bundle

  • :out_dir - the output directory for the bundle, by default this is the /tmp directory
  • :compressed - if the bundle should use compression
  • :verbose - print extra information about each file added to the bundle
  • :prefix - a prefix to the file name generated by saving the bundle. By default this is the current system time in the :native time unit.

Specs

t() :: %{meta: meta(), data: list()}

A bundle

  • :meta - extra info about the containing data and other pieces of information that might be useful a consuming service
  • :data - the data

Specs

target() :: binary()

The target is who the the bundle is created for

This can be Nerves device's serial number or the name of the application using Mobius. This is useful for external services to identify which entity is sending the bundle.

Link to this section Functions

Link to this function

extract(bundle_file, opts \\ [])

View Source

Specs

extract(Path.t(), [extract_opt()]) ::
  {:ok, t()} | {:error, Mobius.Bundle.ExtractError.t()}
Link to this function

new(bundle_target, records)

View Source

Specs

new(target(), [Mobius.record()]) :: t()

Make a new bundle

Link to this function

save(bundle, opts \\ [])

View Source

Specs

save(t(), [save_opt()]) ::
  {:ok, Path.t()} | {:error, Mobius.Bundle.SaveError.t()}

Save a bundle to disk

If saving the bundle works this will print the path to the created bundle. This is useful as often times you might want to do something with bundle shortly after its creation.