Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add provider behaviour, tests, and remove application (#1)
* feat: add provider behaviour * feat: add custom registry * fix(Default): start the correct supervisor * fix(Guild.Registry): add from parameter to handle functions * test: add tests * test: add more tests to guild * deps: temporarily use git dep * chore(.gitignore): add eol eof * fix: add missing @ spec and @ impl * fix(Cache): start_link only accepts one parameter
- Loading branch information
Showing
19 changed files
with
949 additions
and
155 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
defmodule Crux.Cache.Default do | ||
@moduledoc """ | ||
A provider using the default caches: | ||
* `Crux.Cache.Guild` | ||
* `Crux.Cache.Channel` | ||
* `Crux.Cache.Emoji` | ||
* `Crux.Cache.Presence` | ||
* `Crux.Cache.User` | ||
""" | ||
alias Crux.Cache | ||
|
||
use Cache.Provider | ||
|
||
def init(_) do | ||
children = [ | ||
Cache.Guild.Supervisor.Supervisor, | ||
Cache.Channel, | ||
Cache.Emoji, | ||
Cache.Presence, | ||
Cache.User | ||
] | ||
|
||
Supervisor.init(children, strategy: :one_for_one) | ||
end | ||
|
||
@doc """ | ||
The default guild cache. | ||
""" | ||
@impl true | ||
@spec guild_cache() :: module() | ||
def guild_cache(), do: Cache.Guild | ||
|
||
@doc """ | ||
The default guild cache: `Crux.Cache.Channel`. | ||
""" | ||
@impl true | ||
@spec channel_cache() :: module() | ||
def channel_cache(), do: Cache.Channel | ||
|
||
@doc """ | ||
The default guild cache: `Crux.Cache.Emoji`. | ||
""" | ||
@impl true | ||
@spec emoji_cache() :: module() | ||
def emoji_cache(), do: Cache.Emoji | ||
|
||
@doc """ | ||
The default guild cache: `Crux.Cache.Presence`. | ||
""" | ||
@impl true | ||
@spec presence_cache() :: module() | ||
def presence_cache(), do: Cache.Presence | ||
|
||
@doc """ | ||
The default guild cache: `Crux.Cache.User`. | ||
""" | ||
@impl true | ||
@spec user_cache() :: module() | ||
def user_cache(), do: Cache.User | ||
end |
Oops, something went wrong.