diff --git a/README.md b/README.md index 805abff..4742c4e 100644 --- a/README.md +++ b/README.md @@ -2,23 +2,28 @@ [![Hex.pm Version](http://img.shields.io/hexpm/v/smart_city_registry.svg?style=flat)](https://hex.pm/packages/smart_city_registry) # SmartCity.Registry + A library for publishing and updating SmartCity Dataset and Organization definitions, built on top of Redis PubSub. Used for sharing these definitions amongst microservices. This library exposes two sets of functionality. - 1. Definitions for datasets and organizations, and functions for writing them to and fetching them from Redis PubSub. - 2. A subscriber process exposing callbacks that are executed when an update to an organization or dataset is received. + +1. Definitions for datasets and organizations, and functions for writing them to and fetching them from Redis PubSub. +2. A subscriber process exposing callbacks that are executed when an update to an organization or dataset is received. See also: [Redis PubSub](https://redis.io/topics/pubsub) + ## Installation + This package can be installed by adding `smart_city_registry` to your list of dependencies in mix.exs: ```elixir def deps do - [{:smart_city_registry, "~> 5.0.0"}] + [{:smart_city_registry, "~> 5.0.2"}] end ``` ## Basic Usage + ```elixir iex> alias SmartCity.Dataset iex> dataset = Dataset.new(...) @@ -32,6 +37,7 @@ iex> {:ok, dataset} = Dataset.get("some_id") # Get all datasets iex> {:ok, datasets} = Dataset.get_all() ``` + Organization works basically the same way. For receiving updates see the [message handler](#message-handler) and [subscriber](#subscriber) sections below. @@ -39,6 +45,7 @@ For receiving updates see the [message handler](#message-handler) and [subscribe ## Configuration Configure a Redis host: + ```elixir # config/config.exs or #{env}.exs config :smart_city_registry, @@ -48,7 +55,9 @@ config :smart_city_registry, ``` ### Subscriber + Add the subscriber as a child of your application: + ```elixir # application.ex def start(_type, _args) do @@ -62,7 +71,9 @@ end ``` ### Message Handler + Implement a message handler module: + ```elixir # lib/your_app/dataset_handler.ex or wherever defmodule YourApp.DatasetHandler do @@ -82,6 +93,7 @@ end ``` ## Contributing + 1. Fork the repo 2. Make your changes 3. Test your code @@ -101,6 +113,7 @@ mix credo ``` ### Submit a pull request + Submit a PR from your fork back to the [SmartCities/smart_city_registry](https://github.com/SmartCitiesData/smart_city_registry) repository. ## License diff --git a/config/dev.exs b/config/dev.exs index 4768b2c..d2d855e 100644 --- a/config/dev.exs +++ b/config/dev.exs @@ -1,4 +1 @@ use Mix.Config - -config :husky, - pre_commit: "./scripts/git_pre_commit_hook.sh" diff --git a/mix.exs b/mix.exs index 7cf091d..c7b9f14 100644 --- a/mix.exs +++ b/mix.exs @@ -4,7 +4,7 @@ defmodule SmartCity.Registry.MixProject do def project do [ app: :smart_city_registry, - version: "5.0.1", + version: "5.0.2", elixir: "~> 1.8", start_permanent: Mix.env() == :prod, deps: deps(), @@ -27,7 +27,7 @@ defmodule SmartCity.Registry.MixProject do defp deps do [ # Smart City must be unpinned when registry is retired in favor of Discovery API using the event stream - {:smart_city, "2.1.6"}, + {:smart_city, "~> 3.1"}, {:jason, "~> 1.1"}, {:redix, "~> 0.9"}, {:dialyxir, "~> 0.5", only: :dev}, @@ -36,8 +36,7 @@ defmodule SmartCity.Registry.MixProject do {:divo, "~> 1.1", only: [:dev, :test, :integration]}, {:placebo, "~> 1.2", only: [:dev, :test, :integration]}, {:mix_test_watch, "~> 0.9", only: :dev, runtime: false}, - {:checkov, "~> 0.4", only: :test}, - {:husky, "~> 1.0", only: :dev, runtime: false} + {:checkov, "~> 0.4", only: :test} ] end diff --git a/mix.lock b/mix.lock index c7c11d7..e9e7829 100644 --- a/mix.lock +++ b/mix.lock @@ -1,4 +1,5 @@ %{ + "brook_serializer": {:hex, :brook_serializer, "2.0.0", "e12e742d6a533b3820615edb9dd33791f68b7233123d8e7a9db77edb29706aa1", [:mix], [{:jason, "~> 1.1", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm"}, "bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], [], "hexpm"}, "checkov": {:hex, :checkov, "0.4.0", "a1974a5885f62f8943a9059f0d5252b222271e0e58dd872ffb60323f2e376433", [:mix], [], "hexpm"}, "credo": {:hex, :credo, "1.1.5", "caec7a3cadd2e58609d7ee25b3931b129e739e070539ad1a0cd7efeeb47014f4", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm"}, @@ -12,11 +13,12 @@ "makeup": {:hex, :makeup, "1.0.0", "671df94cf5a594b739ce03b0d0316aa64312cee2574b6a44becb83cd90fb05dc", [:mix], [{:nimble_parsec, "~> 0.5.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm"}, "makeup_elixir": {:hex, :makeup_elixir, "0.14.0", "cf8b7c66ad1cff4c14679698d532f0b5d45a3968ffbcbfd590339cb57742f1ae", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm"}, "meck": {:hex, :meck, "0.8.13", "ffedb39f99b0b99703b8601c6f17c7f76313ee12de6b646e671e3188401f7866", [:rebar3], [], "hexpm"}, + "mime": {:hex, :mime, "1.3.1", "30ce04ab3175b6ad0bdce0035cba77bba68b813d523d1aac73d9781b4d193cf8", [:mix], [], "hexpm"}, "mix_test_watch": {:hex, :mix_test_watch, "0.9.0", "c72132a6071261893518fa08e121e911c9358713f62794a90c95db59042af375", [:mix], [{:file_system, "~> 0.2.1 or ~> 0.3", [hex: :file_system, repo: "hexpm", optional: false]}], "hexpm"}, "nimble_parsec": {:hex, :nimble_parsec, "0.5.1", "c90796ecee0289dbb5ad16d3ad06f957b0cd1199769641c961cfe0b97db190e0", [:mix], [], "hexpm"}, "patiently": {:hex, :patiently, "0.2.0", "67eb139591e10c4b363ae0198e832552f191c58894731efd3bf124ec4722267a", [:mix], [], "hexpm"}, "placebo": {:hex, :placebo, "1.2.2", "a3d47906b01844bfd04ab0351a605620619fdb8f011225e406696f96a88ff380", [:mix], [{:meck, "~> 0.8.13", [hex: :meck, repo: "hexpm", optional: false]}], "hexpm"}, "redix": {:hex, :redix, "0.10.2", "a9eabf47898aa878650df36194aeb63966d74f5bd69d9caa37babb32dbb93c5d", [:mix], [{:telemetry, "~> 0.4.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm"}, - "smart_city": {:hex, :smart_city, "2.1.6", "88180173faa62032feddcc427d80465e056c46e8b17609a86633070ff44f86a1", [:mix], [], "hexpm"}, + "smart_city": {:hex, :smart_city, "3.1.0", "c086f955fcaedbd808c93ca7b923f7401e28ec33fd51656188d8b2f495b765c3", [:mix], [{:brook_serializer, "~> 2.0", [hex: :brook_serializer, repo: "hexpm", optional: false]}, {:jason, "~> 1.1", [hex: :jason, repo: "hexpm", optional: false]}, {:mime, "~> 1.3", [hex: :mime, repo: "hexpm", optional: false]}], "hexpm"}, "telemetry": {:hex, :telemetry, "0.4.0", "8339bee3fa8b91cb84d14c2935f8ecf399ccd87301ad6da6b71c09553834b2ab", [:rebar3], [], "hexpm"}, } diff --git a/scripts/git_pre_commit_hook.sh b/scripts/git_pre_commit_hook.sh deleted file mode 100755 index 9843e47..0000000 --- a/scripts/git_pre_commit_hook.sh +++ /dev/null @@ -1,38 +0,0 @@ -#! /bin/bash -RED='\033[0;31m' -NC='\033[0m' # No Color -exit_code=0 - -#Check that version in README.md matches what is in mix.exs -build_output=$(mix hex.build) -current_version=$(echo "$build_output" | grep 'Version:' | awk '{print $2}') -app_name=$(echo "$build_output" | grep 'Building' | awk '{print $2}') -grep -q "{:$app_name, \"~> $current_version" README.md -if [ $? == 1 ]; then - echo -e "${RED}Update the version number in README.md to $current_version\r\n" - exit_code=1 -fi - -mix format - -echo -e "${NC}mix credo - compiling code there may be a delay" -compile_output=$(mix compile 2>/dev/null) ##Supress compile output and warnings - -credo_output=$(mix credo --format=oneline) -if [ $? != 0 ]; then - echo -e "${RED}$credo_output${NC}\r\n" - exit_code=1 -fi - -outdated_output=$(mix hex.outdated) -if [ $? == 1 ]; then - echo -e "${NC}Outdated dependencies" - echo -e "$outdated_output" | grep "Dependency" - echo -en "${RED}" - echo -e "$outdated_output" | grep " No" - echo -e "$outdated_output" | grep " Yes" - echo -e "${NC}" - exit_code=1 -fi - -exit $exit_code \ No newline at end of file