-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
revisit plugins, turn them into GenServers
- Loading branch information
1 parent
f13b454
commit 9aa094e
Showing
6 changed files
with
176 additions
and
121 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,30 @@ | ||
defmodule GriffinSSG.Plugin.Behaviour do | ||
@moduledoc """ | ||
This is the behaviour for all plugins. | ||
The behaviour for a Griffin Plugin. | ||
A Plugin is a stateful process that is started at the beginning of the | ||
Griffin build run and that requests callbacks at specific stages of the build | ||
run by setting up hooks. The arguments passed in to each callback depend on | ||
the hook itself, see `GriffinSSG.hooks()` for more information on hooks. | ||
## Process instances | ||
At this moment, Plugins functions are called globally, e.g. `MyPlugin.list_hooks()`. | ||
This assumes there won't be multiple instances of the same Plugin. | ||
## Errors | ||
Plugins are expected to return errors and not raise if there are issues, so | ||
that the global Griffin run process can show a human friendly error message | ||
and gracefully terminate. | ||
""" | ||
|
||
@callback init(GriffinSSG.Config.t(), any()) :: | ||
{:ok, %{state: term(), hooks: GriffinSSG.hooks()}} | ||
@doc """ | ||
The Plugin start_link function. People creating plugins are encouraged to use | ||
GenServers for their implementation. | ||
""" | ||
@callback start_link(griffin_config :: GriffinSSG.Config.t(), plugin_opts :: any()) :: | ||
{:ok, pid()} | {:error, reason :: atom()} | ||
|
||
@doc """ | ||
Returns a list of Griffin hooks that the Plugin requires. | ||
""" | ||
@callback list_hooks() :: GriffinSSG.hooks() | ||
end |
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 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
Oops, something went wrong.