diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 44bf74e..6e9e797 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -13,7 +13,7 @@ jobs: with: otp-version: 22.3 elixir-version: 1.10.4 - - name: Get depedencies + - name: Get dependencies run: | mix local.rebar --force mix local.hex --force diff --git a/.gitignore b/.gitignore index 76ae68b..23cf0ea 100644 --- a/.gitignore +++ b/.gitignore @@ -22,4 +22,8 @@ erl_crash.dump # Ignore package tarball (built via "mix hex.build"). elsa-*.tar +# Temporary files, for example, from tests. +/tmp/ + +# Misc. .plt/ diff --git a/LICENSE b/LICENSE index d645695..f433b1a 100644 --- a/LICENSE +++ b/LICENSE @@ -175,28 +175,3 @@ of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/README.md b/README.md index d80e06b..b7c6e26 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,12 @@ # Elsa +[![Master](https://github.com/bbalser/elsa/actions/workflows/master.yml/badge.svg)](https://github.com/bbalser/elsa/actions/workflows/master.yml) +[![Module Version](https://img.shields.io/hexpm/v/elsa.svg)](https://hex.pm/packages/elsa) +[![Hex Docs](https://img.shields.io/badge/hex-docs-lightgreen.svg)](https://hexdocs.pm/elsa/) +[![Total Download](https://img.shields.io/hexpm/dt/elsa.svg)](https://hex.pm/packages/elsa) +[![License](https://img.shields.io/hexpm/l/elsa.svg)](https://github.com/bbalser/elsa/blob/master/LICENSE) +[![Last Updated](https://img.shields.io/github/last-commit/bbalser/elsa.svg)](https://github.com/bbalser/elsa/commits/master) + ## Description Elsa is a full-featured Kafka library written in Elixir and extending the `:brod` library with additional support from the `:kafka_protocol` Erlang libraries to provide capabilities not available in `:brod`. @@ -13,12 +20,12 @@ As Elsa draws from the Brod library (named for Kafka friend and biographer Max B ## Installation -The package can be installed by adding `elsa` to your list of dependencies in `mix.exs`: +The package can be installed by adding `:elsa` to your list of dependencies in `mix.exs`: ```elixir def deps do [ - {:elsa, "~> 1.0.0-rc.2"} + {:elsa, "~> 1.0.0-rc.3"} ] end ``` @@ -77,3 +84,17 @@ You can find an example of configuring and using Elsa [here](https://github.com/ ## Testing Elsa uses the standard ExUnit testing library for unit testing. For integration testing interactions with Kafka, it uses the [`divo`](https://github.com/smartcitiesdata/divo) library. Run tests with the command `mix test.integration`. + +## Copyright and License + +Copyright (c) 2019 Brian Balser, Jeff Grunewald, and Johnson Denen + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at [https://www.apache.org/licenses/LICENSE-2.0](https://www.apache.org/licenses/LICENSE-2.0) + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/config/docs.exs b/config/docs.exs new file mode 100644 index 0000000..d2d855e --- /dev/null +++ b/config/docs.exs @@ -0,0 +1 @@ +use Mix.Config diff --git a/lib/elsa.ex b/lib/elsa.ex index 5f27bc2..5878d91 100644 --- a/lib/elsa.ex +++ b/lib/elsa.ex @@ -1,6 +1,6 @@ defmodule Elsa do @moduledoc """ - Provides public api to Elsa. Top-level short-cuts to sub-module functions + Provides public API to Elsa. Top-level short-cuts to sub-module functions for performing basic interactions with Kafka including listing, creating, deleting, and validating topics. Also provides a function for one-off produce_sync of message(s) to a topic. @@ -32,7 +32,7 @@ defmodule Elsa do the Kafka cluster by producers and consumers. Useful for optimizing interactions by passing the identifier of a standing connection instead of instantiating a new one at each interaction, but when only a single connection - is required, aleviating the need for the caller to differentiate and pass + is required, alleviating the need for the caller to differentiate and pass around a name. """ @spec default_client() :: atom() diff --git a/lib/elsa/consumer.ex b/lib/elsa/consumer.ex index a368dd5..8242cb8 100644 --- a/lib/elsa/consumer.ex +++ b/lib/elsa/consumer.ex @@ -1,6 +1,6 @@ defmodule Elsa.Consumer do @moduledoc """ - Public api to consumer acks asynchronously for simple consumers + Public API to consumer acks asynchronously for simple consumers """ import Elsa.Supervisor, only: [registry: 1] diff --git a/lib/elsa/consumer/worker.ex b/lib/elsa/consumer/worker.ex index 504b986..9b1275a 100644 --- a/lib/elsa/consumer/worker.ex +++ b/lib/elsa/consumer/worker.ex @@ -174,7 +174,7 @@ defmodule Elsa.Consumer.Worker do case :brod_consumer.subscribe(consumer_pid, self(), opts) do {:error, reason} -> Logger.warn( - "Retrying to subscribe to topic #{state.topic} parition #{state.partition} offset #{state.offset} reason #{ + "Retrying to subscribe to topic #{state.topic} partition #{state.partition} offset #{state.offset} reason #{ inspect(reason) }" ) diff --git a/lib/elsa/producer.ex b/lib/elsa/producer.ex index 7603559..8251f5c 100644 --- a/lib/elsa/producer.ex +++ b/lib/elsa/producer.ex @@ -10,7 +10,7 @@ defmodule Elsa.Producer do * If a list of messages is supplied as the value, the key is defaulted to an empty string binary. * Partition can be specified by the keyword option `partition:` and an integer corresponding to a specific partition, or the keyword option `partitioner:` and the atoms `:md5` or `:random`. The atoms - correspond to partitioner functions that will uniformely select a random partition + correspond to partitioner functions that will uniformly select a random partition from the total available topic partitions or assign an integer based on an md5 hash of the messages. """ diff --git a/lib/elsa/registry.ex b/lib/elsa/registry.ex index 1e0f5cc..b7e13fe 100644 --- a/lib/elsa/registry.ex +++ b/lib/elsa/registry.ex @@ -61,7 +61,7 @@ defmodule Elsa.Registry do end @doc """ - Start the Elsa registery process and link it to the current process. + Start the Elsa registry process and link it to the current process. Creates the process registry table in ETS and traps exits during the init process. """ diff --git a/mix.exs b/mix.exs index bf1fafa..41f9866 100644 --- a/mix.exs +++ b/mix.exs @@ -14,11 +14,11 @@ defmodule Elsa.MixProject do description: description(), package: package(), deps: deps(), - homepage: @github, docs: docs(), elixirc_paths: elixirc_paths(Mix.env()), test_paths: test_paths(Mix.env()), - dialyzer: [plt_file: {:no_warn, ".plt/#{System.version()}.plt"}] + dialyzer: [plt_file: {:no_warn, ".plt/#{System.version()}.plt"}], + preferred_cli_env: [docs: :docs] ] end @@ -36,7 +36,7 @@ defmodule Elsa.MixProject do {:divo_kafka, "~> 0.1.7", only: [:dev, :test, :integration]}, {:placebo, "~> 2.0", only: [:dev, :test]}, {:checkov, "~> 1.0", only: [:test, :integration]}, - {:ex_doc, "~> 0.25.3", only: [:dev]}, + {:ex_doc, ">= 0.0.0", only: [:docs], runtime: false}, {:dialyxir, "~> 1.1.0", only: [:dev], runtime: false} ] end @@ -50,7 +50,7 @@ defmodule Elsa.MixProject do defp package do [ maintainers: ["Brian Balser", "Jeff Grunewald", "Johnson Denen"], - licenses: ["Apache 2.0"], + licenses: ["Apache-2.0"], links: %{"GitHub" => @github} ] end @@ -61,10 +61,15 @@ defmodule Elsa.MixProject do defp docs do [ - source_ref: "v#{@version}", + extras: [ + "LICENSE": [title: "License"], + "README.md": [title: "Overview"] + ], + main: "readme", + homepage_url: @github, source_url: @github, - extras: ["README.md"], - source_url_pattern: "#{@github}/blob/master/%{path}#L%{line}" + source_ref: "master", + formatters: ["html"] ] end end diff --git a/mix.lock b/mix.lock index 60879ee..cca541b 100644 --- a/mix.lock +++ b/mix.lock @@ -7,7 +7,7 @@ "divo_kafka": {:hex, :divo_kafka, "0.1.7", "e8253bb735e001c41f35645ac0429740b6b6350ceb0ae268609f769f0b3883c5", [:mix], [{:divo, "~> 1.1", [hex: :divo, repo: "hexpm", optional: false]}], "hexpm", "25f9b89a1f59f6801b8b1e044eaa8cdce4e0756b4a8512458ea31f9c99ec338f"}, "earmark_parser": {:hex, :earmark_parser, "1.4.17", "6f3c7e94170377ba45241d394389e800fb15adc5de51d0a3cd52ae766aafd63f", [:mix], [], "hexpm", "f93ac89c9feca61c165b264b5837bf82344d13bebc634cd575cb711e2e342023"}, "erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"}, - "ex_doc": {:hex, :ex_doc, "0.25.5", "ac3c5425a80b4b7c4dfecdf51fa9c23a44877124dd8ca34ee45ff608b1c6deb9", [:mix], [{:earmark_parser, "~> 1.4.0", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "688cfa538cdc146bc4291607764a7f1fcfa4cce8009ecd62de03b27197528350"}, + "ex_doc": {:hex, :ex_doc, "0.26.0", "1922164bac0b18b02f84d6f69cab1b93bc3e870e2ad18d5dacb50a9e06b542a3", [:mix], [{:earmark_parser, "~> 1.4.0", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "2775d66e494a9a48355db7867478ffd997864c61c65a47d31c4949459281c78d"}, "jason": {:hex, :jason, "1.2.2", "ba43e3f2709fd1aa1dce90aaabfd039d000469c05c56f0b8e31978e03fa39052", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "18a228f5f0058ee183f29f9eae0805c6e59d61c3b006760668d8d18ff0d12179"}, "kafka_protocol": {:hex, :kafka_protocol, "4.0.1", "fc696880c73483c8b032c4bb60f2873046035c7824e1edcb924cfce643cf23dd", [:rebar3], [{:crc32cer, "0.1.8", [hex: :crc32cer, repo: "hexpm", optional: false]}], "hexpm", "687bfd9989998ec8fbbc3ed50d1239a6c07a7dc15b52914ad477413b89ecb621"}, "makeup": {:hex, :makeup, "1.0.5", "d5a830bc42c9800ce07dd97fa94669dfb93d3bf5fcf6ea7a0c67b2e0e4a7f26c", [:mix], [{:nimble_parsec, "~> 0.5 or ~> 1.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "cfa158c02d3f5c0c665d0af11512fed3fba0144cf1aadee0f2ce17747fba2ca9"}, diff --git a/test/unit/elsa/consumer/worker_test.exs b/test/unit/elsa/consumer/worker_test.exs index 26adec6..3e98394 100644 --- a/test/unit/elsa/consumer/worker_test.exs +++ b/test/unit/elsa/consumer/worker_test.exs @@ -34,7 +34,7 @@ defmodule Elsa.Consumer.WorkerTest do [messages: messages, state: create_state(init_args)] end - data_test "handler can specifiy offset to ack", %{messages: messages, state: state} do + data_test "handler can specify offset to ack", %{messages: messages, state: state} do set_handler(fn messages -> offset = messages |> List.first() |> Map.get(:offset) {ack, offset}