View Source Smee.Fetch (Smee v0.5.0)

Downloads or loads the metadata specified in a %Smee.Source{} struct and returns a %Smee.Metadata{} struct.

The fetch!/2 and fetch/2 functions can handle both remote and local sources, but sometimes it can be reassuring to prevent unexpected behaviour (perhaps if using a source defined by a user) so Smee.Fetch also contains local!/2 and remote!/2 which will each only accept certain types of sources.

This module will do the work of creating suitable Metadata structs for you, so you should not normally need to create Metadata structs directly yourself.

Summary

Functions

Uses the passed Source struct to load or download the requested metadata XML, and returns a Metadata struct containing the XML inside an :ok tuple.

Uses the passed Source struct to load or download the requested metadata XML, and returns a Metadata struct containing the XML.

Uses the passed Source struct to load the requested metadata XML, and returns a Metadata struct containing the XML in an :ok tuple

Uses the passed Source struct to load the requested metadata XML, and returns a Metadata struct containing the XML

Connects to a remote Source and uses HEAD HTTP method, with no caching, to fetch version/change information from headers.

Uses the passed Source struct to download the requested metadata XML, and returns a Metadata struct containing the XML in an :ok/:error tuple.

Uses the passed Source struct to download the requested metadata XML, and returns a Metadata struct containing the XML

Downloads one or more Sources in parallel and caches the result in the HTTP cache.

Functions

Link to this function

fetch(source, options \\ [])

View Source
@spec fetch(source :: Smee.Source.t(), options :: keyword()) ::
  {:ok, Smee.Metadata.t()} | {:error, any()}

Uses the passed Source struct to load or download the requested metadata XML, and returns a Metadata struct containing the XML inside an :ok tuple.

Works with all types of Source, even MDQ services.

Link to this function

fetch!(source, options \\ [])

View Source
@spec fetch!(source :: Smee.Source.t(), options :: keyword()) :: Smee.Metadata.t()

Uses the passed Source struct to load or download the requested metadata XML, and returns a Metadata struct containing the XML.

Works with all types of Source, even MDQ services.

Will raise an exception on any errors.

Link to this function

local(source, options \\ [])

View Source
@spec local(source :: Smee.Source.t(), options :: keyword()) ::
  {:ok, Smee.Metadata.t()} | {:error, any()}

Uses the passed Source struct to load the requested metadata XML, and returns a Metadata struct containing the XML in an :ok tuple

Works with local Sources including MDQ services but will not accept metadata at a remote URL.

Link to this function

local!(source, options \\ [])

View Source
@spec local!(source :: Smee.Source.t(), options :: keyword()) :: Smee.Metadata.t()

Uses the passed Source struct to load the requested metadata XML, and returns a Metadata struct containing the XML

Works with local Sources including MDQ services but will not accept metadata at a remote URL.

Will raise an exception on any errors.

@spec probe(sources :: Smee.Source.t()) :: {:ok, map()} | {:error, any()}

Connects to a remote Source and uses HEAD HTTP method, with no caching, to fetch version/change information from headers.

An :ok tuple containing a map of etag (string) and changed_at (DateTime) will be returned if successful.

Link to this function

remote(source, options \\ [])

View Source
@spec remote(source :: Smee.Source.t(), options :: keyword()) ::
  {:ok, Smee.Metadata.t()} | {:error, any()}

Uses the passed Source struct to download the requested metadata XML, and returns a Metadata struct containing the XML in an :ok/:error tuple.

Works with remote Sources including MDQ services but will not accept metadata in a local file.

Link to this function

remote!(source, options \\ [])

View Source
@spec remote!(source :: Smee.Source.t(), options :: keyword()) :: Smee.Metadata.t()

Uses the passed Source struct to download the requested metadata XML, and returns a Metadata struct containing the XML

Works with remote Sources including MDQ services but will not accept metadata in a local file.

Will raise an exception on any errors.

Link to this function

warm(sources, options \\ [])

View Source
@spec warm(sources :: Smee.Source.t() | list(), options :: keyword()) :: map()

Downloads one or more Sources in parallel and caches the result in the HTTP cache.

A map of source URLs and status codes are returned. A status code of 0 indicates a client error of some sort.

This function is useful for downloading source metadata in advance so that processing can happen immediately.