Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 0 additions & 69 deletions .circleci/config.yml

This file was deleted.

36 changes: 36 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
on: push
name: Build & Test
env:
MIX_ENV: test

jobs:
test:
runs-on: ubuntu-latest
name: Ex${{matrix.elixir}}/OTP${{matrix.otp}}
strategy:
matrix:
elixir: ["1.17.3", "1.18.2"]
otp: ["25.3.2", "26.2.5", "27.2.4"]
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:5.6.2
options: >-
-e "discovery.type=single-node"
-e "xpack.security.enabled=false"
-e "path.repo=/tmp"
--health-cmd "curl -f http://localhost:9200/_cluster/health"
--health-interval 10s
--health-timeout 5s
--health-retries 10
ports:
- 9200:9200
- 9300:9300
steps:
- uses: actions/checkout@v4
- uses: erlef/setup-beam@v1
with:
otp-version: ${{matrix.otp}}
elixir-version: ${{matrix.elixir}}
- run: mix deps.get
- run: mix compile --warnings-as-errors
- run: mix test
17 changes: 0 additions & 17 deletions .travis.yml

This file was deleted.

4 changes: 2 additions & 2 deletions config/config.exs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This file is responsible for configuring your application
# and its dependencies with the aid of the Mix.Config module.
use Mix.Config
import Config

# This configuration is loaded before any dependency and is restricted
# to this project. If another project depends on this project, this
Expand All @@ -22,4 +22,4 @@ use Mix.Config
# here (which is why it is important to import them last).
#
# import_config "#{Mix.env}.exs"
if Mix.env() == :test || Mix.env() == :dev, do: import_config("#{Mix.env()}.exs")
if Mix.env() in [:test, :dev], do: import_config("#{Mix.env()}.exs")
2 changes: 1 addition & 1 deletion config/dev.exs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use Mix.Config
import Config

config :mix_test_watch,
tasks: [
Expand Down
2 changes: 1 addition & 1 deletion config/test.exs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use Mix.Config
import Config

config :elastix,
test_url: "http://127.0.0.1:9200",
Expand Down
7 changes: 5 additions & 2 deletions lib/elastix/bulk.ex
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ defmodule Elastix.Bulk do

(elastic_url <>
make_path(Keyword.get(options, :index), Keyword.get(options, :type), query_params))
|> HTTP.put(Enum.map(lines, fn line -> JSON.encode!(line) <> "\n" end), [], httpoison_options)
|> HTTP.put(
Enum.map(lines, fn line -> JSON.encode!(line) <> "\n" end),
[],
httpoison_options
)
end

@doc """
Expand All @@ -70,7 +74,6 @@ defmodule Elastix.Bulk do
query_params :: Keyword.t()
) :: HTTP.resp()
def post_raw(elastic_url, raw_data, options \\ [], query_params \\ []) do

httpoison_options = Keyword.get(options, :httpoison_options, [])

(elastic_url <>
Expand Down
15 changes: 2 additions & 13 deletions lib/elastix/json.ex
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,10 @@ defmodule Elastix.JSON do

@doc false
defp json_options do
# Support :poison_options config for backward-compatibility
case Elastix.config(:poison_options) do
nil ->
Elastix.config(:json_options, [])

opts ->
IO.warn(
"Using :poison_options is deprecated and might not work in future releases; use :json_options instead."
)

opts
end
Elastix.config(:json_options, [])
end

defp codec do
Elastix.config(:json_codec, Poison)
Elastix.config(:json_codec, Jason)
end
end
18 changes: 14 additions & 4 deletions lib/elastix/snapshot/snapshot.ex
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,14 @@ defmodule Elastix.Snapshot.Snapshot do
"""
@spec create(String.t(), String.t(), String.t(), Map.t(), [tuple()], Keyword.t()) ::
{:ok, %HTTPoison.Response{}}
def create(elastic_url, repo_name, snapshot_name, data \\ %{}, query_params \\ [], options \\ []) do
def create(
elastic_url,
repo_name,
snapshot_name,
data \\ %{},
query_params \\ [],
options \\ []
) do
elastic_url
|> prepare_url(make_path(repo_name, snapshot_name, query_params))
|> HTTP.put(JSON.encode!(data), [], _make_httpoison_options(options))
Expand All @@ -35,7 +42,8 @@ defmodule Elastix.Snapshot.Snapshot do
snapsot. If repo_name is specified, will retrieve the status of all snapshots
in that repository. Otherwise, will retrieve the status of all snapshots.
"""
@spec status(String.t(), String.t(), String.t(), Keyword.t()) :: {:ok, %HTTPoison.Response{}}
@spec status(String.t(), String.t(), String.t(), Keyword.t()) ::
{:ok, %HTTPoison.Response{}}
def status(elastic_url, repo_name \\ "", snapshot_name \\ "", options \\ []) do
elastic_url
|> prepare_url([make_path(repo_name, snapshot_name), "_status"])
Expand All @@ -48,7 +56,8 @@ defmodule Elastix.Snapshot.Snapshot do
all snapshots in that repository. Otherwise, will retrieve information about
all snapshots.
"""
@spec get(String.t(), String.t(), String.t(), Keyword.t()) :: {:ok, %HTTPoison.Response{}}
@spec get(String.t(), String.t(), String.t(), Keyword.t()) ::
{:ok, %HTTPoison.Response{}}
def get(elastic_url, repo_name \\ "", snapshot_name \\ "_all", options \\ []) do
elastic_url
|> prepare_url(make_path(repo_name, snapshot_name))
Expand All @@ -69,7 +78,8 @@ defmodule Elastix.Snapshot.Snapshot do
{:ok, %HTTPoison.Response{...}}

"""
@spec delete(String.t(), String.t(), String.t(), Keyword.t()) :: {:ok, %HTTPoison.Response{}}
@spec delete(String.t(), String.t(), String.t(), Keyword.t()) ::
{:ok, %HTTPoison.Response{}}
def delete(elastic_url, repo_name, snapshot_name, options \\ []) do
elastic_url
|> prepare_url(make_path(repo_name, snapshot_name))
Expand Down
17 changes: 8 additions & 9 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,26 @@ defmodule Elastix.Mixfile do

def application do
[
applications: [:logger, :httpoison, :retry]
extra_applications: [:logger, :httpoison]
]
end

defp deps do
[
{:ex_doc, ">= 0.0.0", only: :dev, runtime: false},
{:credo, "~> 0.6", only: [:dev, :test]},
{:mix_test_watch, "~> 0.3", only: [:test, :dev]},
{:poison, "~> 3.0 or ~> 4.0", optional: true},
{:httpoison, "~> 1.4"},
{:retry, "~> 0.8"}
{:ex_doc, "~> 0.27", only: :dev, runtime: false},
{:credo, "~> 1.7", only: [:dev, :test]},
{:jason, "~> 1.4", optional: true},
{:httpoison, "~> 2.2"},
{:retry, "~> 0.8", only: [:dev, :test]}
]
end

defp package do
[
description: "A DSL-free Elastic / Elasticsearch client for Elixir.",
files: ["lib", "mix.exs", "README.md", "CHANGELOG.md", "LICENSE"],
maintainers: ["El Werbitzky", "evuez <helloevuez@gmail.com>"],
licenses: ["WTFPL-2"],
maintainers: ["El Werbitzky", "evuez <helloevuez@gmail.com>", "Fabian Becker"],
licenses: ["MIT"],
links: %{
"Changelog" => "https://hexdocs.pm/elastix/changelog.html",
"GitHub" => @source_url
Expand Down
Loading
Loading