Dust.Instance (dustlayer v0.1.1)

Copy Markdown View Source

Macro that generates a named Dust facade module from application config.

Usage

defmodule MyApp.Dust do
  use Dust, otp_app: :my_app
end

Then in your config:

config :my_app, MyApp.Dust,
  stores: ["james/blog"],
  cache: {Dust.Cache.Memory, []},
  url: Dust.cloud_url(),
  token: "sk_..."

The default :url is ws://localhost:7755/ws/sync (the local dev server). Use Dust.cloud_url/0 to target the hosted service at dustlayer.io.

And in your supervision tree:

children = [
  MyApp.Dust
]

The facade delegates all public API functions (get, put, delete, etc.) to Dust.SyncEngine, so MyApp.Dust.get("james/blog", "key") is equivalent to Dust.get("james/blog", "key").

Testing mode

Set testing: :manual in config to skip starting the WebSocket connection:

config :my_app, MyApp.Dust,
  stores: ["test/store"],
  cache: {Dust.Cache.Memory, []},
  testing: :manual