Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update car req2 #6

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
161 changes: 161 additions & 0 deletions .github/workflows/elixir.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
name: Elixir CI

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
merge_group:
types: [checks_requested]

permissions:
contents: read

jobs:
build0:
name: Build and test OpenSearch v1.16 OTP26
runs-on: ubuntu-latest

services:
postgres:
image: postgres:12
ports: ['5432:5432']
env:
POSTGRES_HOST_AUTH_METHOD: trust
POSTGRES_PASSWORD: ""
options: --health-cmd pg_isready --health-interval 10s --health-timeout 10s --health-retries 5

steps:
- uses: actions/checkout@v4

- name: Run OpenSearch
uses: esmarkowski/[email protected]
with:
version: 2.15.0
security-disabled: true

- name: Set up Elixir v1.16 OTP26
uses: erlef/setup-beam@v1
with:
elixir-version: "1.16.X" # Define the elixir version [required]
otp-version: "26.X" # Define the OTP version [required]

- name: Install dependencies
run: mix deps.get

# Step: Compile the project treating any warnings as errors.
- name: Compiles without warnings
run: mix compile --force --warnings-as-errors

# Step: Check that the checked in code has already been formatted.
- name: Check Formatting
run: mix format --check-formatted

- name: Run tests v1.16 OTP26
env:
DATABASE_HOST: localhost
MIX_ENV: test
run: mix test

build1:
name: Build and test OpenSearch v1.17 OTP26
runs-on: ubuntu-latest

services:
postgres:
image: postgres:12
ports: ['5432:5432']
env:
POSTGRES_HOST_AUTH_METHOD: trust
POSTGRES_PASSWORD: ""
options: --health-cmd pg_isready --health-interval 10s --health-timeout 10s --health-retries 5

steps:
- uses: actions/checkout@v4

- name: Run OpenSearch
uses: esmarkowski/[email protected]
with:
version: 2.15.0
security-disabled: true

- name: Set up Elixir v1.17 OTP26
uses: erlef/setup-beam@v1
with:
elixir-version: "1.17.X" # Define the elixir version [required]
otp-version: "26.X" # Define the OTP version [required]
- name: Install dependencies
run: mix deps.get
- name: Run tests v1.17 OTP26
env:
DATABASE_HOST: localhost
MIX_ENV: test
run: mix test

build2:
name: Build and test ElasticSearch v1.16 OTP26
runs-on: ubuntu-latest

services:
postgres:
image: postgres:12
ports: ['5432:5432']
env:
POSTGRES_HOST_AUTH_METHOD: trust
POSTGRES_PASSWORD: ""
options: --health-cmd pg_isready --health-interval 10s --health-timeout 10s --health-retries 5

steps:
- uses: actions/checkout@v4

- name: Run Elasticsearch
uses: elastic/elastic-github-actions/elasticsearch@master
with:
stack-version: 7.17.24

- name: Set up Elixir v1.16 OTP26
uses: erlef/setup-beam@v1
with:
elixir-version: "1.16.X" # Define the elixir version [required]
otp-version: "26.X" # Define the OTP version [required]
- name: Install dependencies
run: mix deps.get
- name: Run tests v1.17 OTP26
env:
DATABASE_HOST: localhost
MIX_ENV: test
run: mix test

build3:
name: Build and test ElasticSearch v1.17 OTP26
runs-on: ubuntu-latest

services:
postgres:
image: postgres:12
ports: ['5432:5432']
env:
POSTGRES_HOST_AUTH_METHOD: trust
POSTGRES_PASSWORD: ""
options: --health-cmd pg_isready --health-interval 10s --health-timeout 10s --health-retries 5

steps:
- uses: actions/checkout@v4

- name: Run Elasticsearch
uses: elastic/elastic-github-actions/elasticsearch@master
with:
stack-version: 7.17.24

- name: Set up Elixir v1.17 OTP26
uses: erlef/setup-beam@v1
with:
elixir-version: "1.17.X" # Define the elixir version [required]
otp-version: "26.X" # Define the OTP version [required]
- name: Install dependencies
run: mix deps.get
- name: Run tests v1.17 OTP26
env:
DATABASE_HOST: localhost
MIX_ENV: test
run: mix test
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ config :my_app, MyApp.ElasticsearchCluster,
api: Elasticsearch.API.HTTP,

# Customize the library used for JSON encoding/decoding.
json_library: Poison, # or Jason
json_library: Jason

# You should configure each index which you maintain in Elasticsearch here.
# This configuration will be read by the `mix elasticsearch.build` task,
Expand Down Expand Up @@ -212,14 +212,18 @@ end

As AWS does not provide credentials' based http authentication, you can use the `Elasticsearch.API.AWS` module if you want to use AWS Elasticsearch Service with AWS Signature V4 signed HTTP connections.

To use this, just add `sigaws` to your dependencies and add this to your configuration:
AWS signatures are now supported in Req directly. See https://github.com/wojtekmach/req?tab=readme-ov-file#features

(put_aws_sigv4/1)[https://hexdocs.pm/req/Req.Steps.html#put_aws_sigv4/1]

~To use this, just add `sigaws` to your dependencies and add this to your configuration:~

```elixir
# Add to deps
# Add to deps
def deps do
[
# ...
{:sigaws, ">= 0.0.0"}
[
# probably no longer needed. Remove when we verify req supports this natively.
# {:sigaws, ">= 0.0.0"}
]
end

Expand Down
8 changes: 0 additions & 8 deletions bin/coverage

This file was deleted.

11 changes: 0 additions & 11 deletions coveralls.json

This file was deleted.

15 changes: 10 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,14 @@ services:
- "5432:5432"
environment:
POSTGRES_HOST_AUTH_METHOD: "trust"
elasticsearch:
# image: docker.elastic.co/elasticsearch/elasticsearch:7.10.2
image: docker.elastic.co/elasticsearch/elasticsearch:6.8.13
opensearch:
container_name: opensearch
restart: always
image: opensearchproject/opensearch:2.15.0

# elasticsearch:
# # image: docker.elastic.co/elasticsearch/elasticsearch:7.10.2
# image: docker.elastic.co/elasticsearch/elasticsearch:6.8.13
environment:
- node.name=es01
- bootstrap.memory_lock=true
Expand All @@ -31,10 +36,10 @@ services:
consistency: delegated
environment:
- "DATABASE_HOST=db"
- "ELASTICSEARCH_HOST=elasticsearch"
- "ELASTICSEARCH_HOST=opensearch"
depends_on:
- db
- elasticsearch
- opensearch
links:
- db:postgres
volumes:
Expand Down
11 changes: 2 additions & 9 deletions lib/elasticsearch.ex
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ defmodule Elasticsearch do
"_primary_term" => 1,
"_seq_no" => 0,
"_shards" => %{"failed" => 0, "successful" => 1, "total" => 2},
"_type" => "_doc",
"_version" => 1,
"result" => "created"
}}
Expand Down Expand Up @@ -84,7 +83,6 @@ defmodule Elasticsearch do
# => "_primary_term" => 1,
# => "_seq_no" => 0,
# => "_shards" => %{"failed" => 0, "successful" => 1, "total" => 2},
# => "_type" => "_doc",
# => "_version" => 1,
# => "result" => "created"
# => }}
Expand All @@ -108,7 +106,6 @@ defmodule Elasticsearch do
"_primary_term" => 1,
"_seq_no" => 0,
"_shards" => %{"failed" => 0, "successful" => 1, "total" => 2},
"_type" => "_doc",
"_version" => 1,
"result" => "created"
}
Expand Down Expand Up @@ -136,7 +133,6 @@ defmodule Elasticsearch do
"_primary_term" => 1,
"_seq_no" => 1,
"_shards" => %{"failed" => 0, "successful" => 1, "total" => 2},
"_type" => "_doc",
"_version" => 2,
"result" => "deleted"
}}
Expand All @@ -161,7 +157,6 @@ defmodule Elasticsearch do
"_primary_term" => 1,
"_seq_no" => 1,
"_shards" => %{"failed" => 0, "successful" => 1, "total" => 2},
"_type" => "_doc",
"_version" => 2,
"result" => "deleted"
}
Expand Down Expand Up @@ -287,15 +282,14 @@ defmodule Elasticsearch do
"_primary_term" => 1,
"_seq_no" => 0,
"_shards" => %{"failed" => 0, "successful" => 1, "total" => 2},
"_type" => "_doc",
"_version" => 1,
"result" => "created"
}}

iex> Elasticsearch.put(Cluster, "/bad/url", %{"title" => "title", "author" => "author"})
{:error,
%Elasticsearch.Exception{col: nil, line: nil,
message: "Incorrect HTTP method for uri [/bad/url] and method [PUT], allowed: [POST]",
message: "no handler found for uri [/bad/url] and method [PUT]",
query: nil, raw: nil, status: nil, type: nil}}
"""
@spec put(Cluster.t(), url, data) :: response
Expand All @@ -322,13 +316,12 @@ defmodule Elasticsearch do
"_primary_term" => 1,
"_seq_no" => 0,
"_shards" => %{"failed" => 0, "successful" => 1, "total" => 2},
"_type" => "_doc",
"_version" => 1,
"result" => "created"
}

iex> Elasticsearch.put!(Cluster, "/bad/url", %{"data" => "here"})
** (Elasticsearch.Exception) Incorrect HTTP method for uri [/bad/url] and method [PUT], allowed: [POST]
** (Elasticsearch.Exception) no handler found for uri [/bad/url] and method [PUT]
"""
@spec put!(Cluster.t(), url, data) :: map | no_return
@spec put!(Cluster.t(), url, data, opts) :: map | no_return
Expand Down
Loading
Loading