forked from breakroom/snap
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
236 additions
and
12 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,16 +1,19 @@ | ||
defmodule Snap.Auth do | ||
@moduledoc """ | ||
The `Snap.Auth` behaviour can be implemented by modules to define how `snap` | ||
transforms HTTP requests to add authentication. | ||
Defines how HTTP request is transformed to add authentication. | ||
""" | ||
|
||
@type method :: String.t() | ||
@type path :: String.t() | ||
@type url :: String.t() | ||
@type headers :: Mint.Types.headers() | ||
@type body :: iodata() | ||
@type opts :: Keyword.t() | ||
@type config :: map() | ||
|
||
@type response :: {:ok, {method, path, headers, body}} | {:error, term()} | ||
@type response :: {:ok, {method, url, headers, body}} | {:error, term()} | ||
|
||
@callback sign(map(), method, path, headers, body) :: response() | ||
@doc """ | ||
Modifies an HTTP request to include authentication details | ||
""" | ||
@callback sign(config, method, url, headers, body) :: response() | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,58 @@ | ||
defmodule Snap.Bulk.Action.Create do | ||
@moduledoc """ | ||
Represents a create step in a `Snap.Bulk` operation | ||
""" | ||
@enforce_keys [:doc] | ||
defstruct [:_index, :_id, :require_alias, :doc] | ||
|
||
@type t :: %__MODULE__{ | ||
_index: String.t() | nil, | ||
_id: String.t() | nil, | ||
require_alias: boolean() | nil, | ||
doc: map() | ||
} | ||
end | ||
|
||
defmodule Snap.Bulk.Action.Delete do | ||
@moduledoc """ | ||
Represents a delete step in a `Snap.Bulk` operation | ||
""" | ||
@enforce_keys [:_id] | ||
defstruct [:_index, :_id, :require_alias] | ||
|
||
@type t :: %__MODULE__{ | ||
_index: String.t() | nil, | ||
_id: String.t(), | ||
require_alias: boolean() | nil | ||
} | ||
end | ||
|
||
defmodule Snap.Bulk.Action.Index do | ||
@moduledoc """ | ||
Represents an index step in a `Snap.Bulk` operation | ||
""" | ||
@enforce_keys [:doc] | ||
defstruct [:_index, :_id, :require_alias, :doc] | ||
|
||
@type t :: %__MODULE__{ | ||
_index: String.t() | nil, | ||
_id: String.t() | nil, | ||
require_alias: boolean() | nil, | ||
doc: map() | ||
} | ||
end | ||
|
||
defmodule Snap.Bulk.Action.Update do | ||
@moduledoc """ | ||
Represents an update step in a `Snap.Bulk` operation | ||
""" | ||
@enforce_keys [:doc] | ||
defstruct [:_index, :_id, :require_alias, :doc] | ||
|
||
@type t :: %__MODULE__{ | ||
_index: String.t() | nil, | ||
_id: String.t() | nil, | ||
require_alias: boolean() | nil, | ||
doc: map() | ||
} | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
defmodule Snap.Bulk.Actions do | ||
@moduledoc false | ||
|
||
alias Snap.Bulk.Action.{Create, Index, Update, Delete} | ||
|
||
@doc """ | ||
|
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,4 +1,5 @@ | ||
defmodule Snap.Config do | ||
@moduledoc false | ||
use GenServer | ||
|
||
def start_link({name, config}) do | ||
|
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,4 +1,6 @@ | ||
defmodule Snap.Cluster.Supervisor do | ||
@moduledoc false | ||
|
||
use Supervisor | ||
@default_pool_size 5 | ||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
defmodule Snap.Test.Cluster do | ||
@moduledoc false | ||
use Snap.Cluster, otp_app: :snap | ||
|
||
def init(config) do | ||
|
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,4 +1,5 @@ | ||
defmodule Snap.IntegrationCase do | ||
@moduledoc false | ||
use ExUnit.CaseTemplate | ||
|
||
alias Snap.Test.Cluster | ||
|