View Source Libmention.StorageApi behaviour (libmention v0.1.4)

The behaviour for required for storing a webmention.

By default ets is used, but implementing this behaviour and setting your configuration value to that implementation, you can use any storage backend you want.

Link to this section Summary

Types

The shape of the webmention passed to the save/update/exists? calls

Callbacks

This is called after a webmention is sent.

This is called when the content of a webmention (sha) changes and we've already and we sent another one.

Link to this section Types

@type entity() :: %{
  source_url: String.t(),
  target_url: String.t(),
  endpoint: String.t(),
  status: :sent | :not_found | :failed | :pending,
  sha: String.t()
}

The shape of the webmention passed to the save/update/exists? calls

Link to this section Callbacks

@callback exists?(entity()) :: boolean()
@callback get(id() | entity()) :: term() | nil
@callback save(entity()) :: {:ok, term()} | {:error | term()}

This is called after a webmention is sent.

Saving the webmention result in storage means that we can make better decisions about if we want to send another webmention or not.

@callback update(entity()) :: {:ok, term()} | {:error | term()}

This is called when the content of a webmention (sha) changes and we've already and we sent another one.