View Source Smee.MDQ (Smee v0.5.0)

Smee.MDQ provides a client API to MDQ services, and also attempts to emulate MDQ-style behaviour with old-fashioned metadata aggregates. MDQ allows individual entities to be looked up when needed without downloading and processing an increasingly enormous metadata aggregate file.

Emulation of MDQ for aggregates depends on caching and is usually slower for individual entity lookups even after the initial download and caching is complete.

Summary

Functions

Returns the aggregated XML for the MDQ service as a Metadata struct, if one is available.

Fetches an individual entity's metadata from the MDQ service and returns it as an Entity struct.

Fetches an individual entity's metadata from the MDQ service and returns it as an Entity struct.

Returns a list of all entity ID URIs available at the MDQ service.

Fetches an individual entity's metadata from the MDQ service and returns it as an Entity struct in an :ok/:error tuple.

Fetches an individual entity's metadata from the MDQ service and returns it as an Entity struct.

A convenient shortcut for specifying an MDQ service as a source.

Fetches every entity from the MDQ service one by one and returns them as a stream of Entity structs.

Fetches the specified entities from the MDQ service one by one and returns them as a stream of Entity structs.

If passed an entity ID URI is returns the MDQ "transformed" version of the identifer, based on a sha1 hash.

Returns the full download URL for an entity at the specified service.

Functions

@spec aggregate!(source :: Smee.Source.t()) :: Smee.Metadata.t()

Returns the aggregated XML for the MDQ service as a Metadata struct, if one is available.

@spec get(source :: Smee.Source.t(), entity_id :: binary()) :: Smee.Entity.t() | nil

Fetches an individual entity's metadata from the MDQ service and returns it as an Entity struct.

Get attempts to behave like Ecto's Repo.get - it will return an entity or nil if the entity is unavailable.

@spec get!(source :: Smee.Source.t(), entity_id :: binary()) :: Smee.Entity.t()

Fetches an individual entity's metadata from the MDQ service and returns it as an Entity struct.

Get attempts to behave like Ecto's Repo.get! - it will return an entity or raises an exception if the entity is unavailable.

This is identical to lookup!2 but exists for consistency.

@spec list!(source :: Smee.Source.t()) :: [binary()]

Returns a list of all entity ID URIs available at the MDQ service.

This will probably involve downloading the MDQ service's aggregate in most cases, but this aggregate will be cached.

Link to this function

lookup(source, entity_id)

View Source
@spec lookup(source :: Smee.Source.t(), entity_id :: binary()) ::
  {:ok, Smee.Entity.t()} | {:error, any()}

Fetches an individual entity's metadata from the MDQ service and returns it as an Entity struct in an :ok/:error tuple.

Missing or unknown entities will cause an {:error, :http_404} result.

Link to this function

lookup!(source, entity_id)

View Source
@spec lookup!(source :: Smee.Source.t(), entity_id :: binary()) :: Smee.Entity.t()

Fetches an individual entity's metadata from the MDQ service and returns it as an Entity struct.

This is identical to get!2 but exists for consistency.

Link to this function

source(url, options \\ [])

View Source
@spec source(url :: binary(), options :: keyword()) :: Smee.Source.t()

A convenient shortcut for specifying an MDQ service as a source.

This is functionally identical to using Smee.Source.new(url, type: :mdq)

@spec stream(source :: Smee.Source.t()) :: Enumerable.t()

Fetches every entity from the MDQ service one by one and returns them as a stream of Entity structs.

This stream allows entities to be processed individually, using relatively little memory.

The stream is relatively laid-back even on a fast M1 Mac, but please don't abuse this function and overwhelm public MDQ services.

@spec stream(source :: Smee.Source.t(), ids :: list()) :: Enumerable.t()

Fetches the specified entities from the MDQ service one by one and returns them as a stream of Entity structs.

This stream allows entities to be processed individually, using relatively little memory.

The stream is relatively laid-back even on a fast M1 Mac, but please don't abuse this function and overwhelm public MDQ services.

Link to this function

transform_uri(entity_id)

View Source
@spec transform_uri(entity_id :: binary()) :: binary()

If passed an entity ID URI is returns the MDQ "transformed" version of the identifer, based on a sha1 hash.

Already-transformed identifiers are passed through unchanged.

@spec url(source :: Smee.Source.t(), entity_id :: binary()) :: binary()

Returns the full download URL for an entity at the specified service.