Smee.Source (Smee v0.1.0) View Source

Defines sources for metadata, which can then be Fetched and prodoce Metadata structs. Source structs are the usual starting-place for Smee tasks.

Source structs act as the configuration for metadata creation. They require a URL but various other options can be set and their effect will propagate down to Entity records.

Link to this section Summary

Functions

Attempts to validate a source struct, and will return an :ok/:error tuple containing the Source if it passes checks.

Attempts to validate a source struct, and will return the Source if it passes checks, or raise an exception.

Creates a new source struct, describing where and how to find metadata.

Link to this section Types

Specs

t() :: %Smee.Source{
  auth: nil | keyword(),
  cache: boolean(),
  cert_fingerprint: nil | binary(),
  cert_url: binary(),
  label: nil | binary(),
  priority: integer(),
  redirects: integer(),
  retries: integer(),
  strict: boolean(),
  trustiness: float(),
  type: nil | atom(),
  url: binary()
}

Link to this section Functions

Link to this function

check(source, options \\ [])

View Source

Specs

check(source :: t(), options :: keyword()) :: {:ok, t()} | {:error, binary()}

Attempts to validate a source struct, and will return an :ok/:error tuple containing the Source if it passes checks.

Link to this function

check!(source, options \\ [])

View Source

Specs

check!(source :: t(), options :: keyword()) :: t()

Attempts to validate a source struct, and will return the Source if it passes checks, or raise an exception.

Specs

new(url :: binary(), options :: keyword()) :: t()

Creates a new source struct, describing where and how to find metadata.

The only essential parameter is a URL for the metadata. URLs can have file:, http://, or https:// schemes. Bare filesystem paths can also be passed and will be converted to file: URLs.

MDQ service clients should be configured with the base URL of the service, not the /entity/ endpoint, and a type of :mdq. Alternatively the Smee.MDQ.source/2 function can be used as a shortcut.

Available options include:

  • type: determines the general type of metadata - :aggregate (the default), :single and :mdq
  • cert_url: location of certificate to use when verifying signed metadata
  • cert_fingerprint: SHA1 fingerprint of the signing certificate
  • cache: should HTTP caching be enabled for downloads. true or false, defaults to true.
  • redirects: maximum number of 302 redirects to follow
  • retries: number of retries to attempt
  • label: a relatively useless label for the metadata
  • priority: integer between 0 and 9, used for comparing metadata
  • trustiness: float between 0.0 and 0.9, for comparing metadata
  • strict: defaults to false. If enabled some stricter checks are enabled

MDQ sources are intended for use with the Smee.MDQ API but will also support normal fetch requests.