Skip to content

Commit

Permalink
Merge pull request #24 from beardedeagle/0.3.4_branch
Browse files Browse the repository at this point in the history
0.3.4
  • Loading branch information
beardedeagle authored Aug 20, 2019
2 parents 6d6106c + cff5fb4 commit 8d8b401
Show file tree
Hide file tree
Showing 15 changed files with 100 additions and 67 deletions.
8 changes: 4 additions & 4 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

I welcome any and all ideas, issues and pull requests. Be sure to follow git best practices. A couple of ground rules:

- All code must be formatted.
- All code must be documented.
- All code must pass static analysis/linter checks.
- All code must have test coverage.
- All code must be formatted, when applicable.
- All code must be documented, when applicable.
- All code must pass static analysis/linter checks, when applicable.
- All code must have test coverage, when applicable.

Exceptions should be avoided whenever possible.

Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/BUG_REPORT.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Bug Report
about: Report a bug to help Mnesiac improve.
---

<!-- ⚠️ Failure to follow this template will result in your report being closed. ⚠️ -->
<!-- ⚠️ Be sure to browse the opened/closed issues before submitting your issue. ⚠️ -->

## Version and Environment

Expand Down
1 change: 0 additions & 1 deletion .github/ISSUE_TEMPLATE/FEATURE_REQUEST.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ name: Feature Request
about: Propose a change to Mnesiac.
---

<!-- ⚠️ Failure to follow this template will result in your request being closed. ⚠️ -->
<!-- ⚠️ Be sure to browse the opened/closed issues before submitting your issue. ⚠️ -->

## Proposal
Expand Down
12 changes: 5 additions & 7 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@

## Check list

<!-- ⚠️ Failure to follow this checklist will result in your pull request being closed. ⚠️ -->

- [ ] All new code is formatted.
- [ ] All new code is documented.
- [ ] All new code passed static analysis/linter checks.
- [ ] Added tests to ensure coverage of new code.
- [ ] All tests passed.
- [ ] If applicable, all new code is formatted.
- [ ] If applicable, all new code is documented.
- [ ] If applicable, all new code passed static analysis/linter checks.
- [ ] If applicable, added tests to ensure coverage of new code.
- [ ] If applicable, all tests passed.

## Additional info

Expand Down
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ _build
.elixir_ls
.fetch
.idea
.sobelow
.sonarlint
.vscode
*.beam
Expand All @@ -14,7 +13,7 @@ cover
deps
doc
erl_crash.dump
Mnesia.nonode@nohost
Mnesia.*@*
mnesiac-*.tar
mnesiac.iml
MnesiaCore.*
Expand Down
4 changes: 2 additions & 2 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
erlang 21.2.6
elixir 1.8.1-otp-21
erlang 22.0.7
elixir 1.9.1-otp-22
10 changes: 6 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
sudo: false
language: 'elixir'
elixir:
- '1.7'
- '1.8.1'
- '1.7.4'
- '1.8.2'
- '1.9.1'
otp_release:
- '20.3'
- '21.2.6'
- '20.3.8.22'
- '21.3.8'
- '22.0.7'
git:
quiet: true
env:
Expand Down
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [[0.3.4]] - 2019-08-20
### Fixed
- Logger crashes in `Mnesiac` module.
- copy_table bug, closes #20.

### Changed
- Bumped OTP version.
- Bumped Elixir version.
- Updated dependencies.

## [[0.3.3]] - 2019-02-25
### Fixed
- Apply regression fix to `copy_store/0` and `resolve_conflict/1`.
Expand Down Expand Up @@ -44,6 +54,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Added
- Initial release.

[0.3.4]: https://github.com/beardedeagle/mnesiac/compare/v0.3.3...v0.3.4
[0.3.3]: https://github.com/beardedeagle/mnesiac/compare/v0.3.2...v0.3.3
[0.3.2]: https://github.com/beardedeagle/mnesiac/compare/v0.3.1...v0.3.2
[0.3.1]: https://github.com/beardedeagle/mnesiac/compare/v0.3.0...v0.3.1
Expand Down
2 changes: 2 additions & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Contributors

- astutecat
- darrenclark
- aby2503
48 changes: 30 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

[![Build Status](https://travis-ci.org/beardedeagle/mnesiac.svg?branch=master)](https://travis-ci.org/beardedeagle/mnesiac) [![codecov](https://codecov.io/gh/beardedeagle/mnesiac/branch/master/graph/badge.svg)](https://codecov.io/gh/beardedeagle/mnesiac) [![Hex.pm](http://img.shields.io/hexpm/v/mnesiac.svg?style=flat)](https://hex.pm/packages/mnesiac) [![Hex.pm downloads](https://img.shields.io/hexpm/dt/mnesiac.svg?style=flat)](https://hex.pm/packages/mnesiac)

Mnesia autoclustering made easy!
Mnesia auto clustering made easy!

Docs can be found at [https://hexdocs.pm/mnesiac](https://hexdocs.pm/mnesiac).

**_NOTICE:_** Mnesiac, while stable, is still considered pre `1.0`. This means the api can, and may, change at any time. Please ensure you review the docs and changelog prior to updating.
**_NOTICE:_** Mnesiac, while stable, is still considered pre `1.0`. This means the API can, and may, change at any time. Please ensure you review the docs and changelog prior to updating.

**_NOTICE:_** Mnesiac allows a significant amount of freedom with how it behaves. This allows you to customize Mnesiac to suit your needs. However, this also allows for a fair amount of foot gunning. Please ensure you've done your due diligence when using this library, or Mnesia itself for that matter. It isn't a silver bullet, and it shouldn't be treated as one.

## Installation

Expand All @@ -20,7 +22,7 @@ def deps do
end
```

Edit your app's config.exs to add the list of mnesia stores:
Edit your app's config.exs to add the list of Mnesia stores:

```elixir
config :mnesiac,
Expand All @@ -31,7 +33,7 @@ config :mnesiac,

Then add `mnesiac` to your supervision tree:

- With `libcluster` using the `Cluster.Strategy.Epmd` strategy:
- **_EXAMPLE:_** With `libcluster` using the `Cluster.Strategy.Epmd` strategy:

```elixir
...
Expand All @@ -48,7 +50,7 @@ Then add `mnesiac` to your supervision tree:
...
```

- Without `libcluster`:
- **_EXAMPLE:_** Without `libcluster`:

```elixir
...
Expand All @@ -71,22 +73,29 @@ Then add `mnesiac` to your supervision tree:

### Table creation

Create a table store, `use Mnesiac.Store`, and add it to your app's config.exs.
Create a table store, `use Mnesiac.Store`, and add it to your app's config.exs.

All stores *MUST* implement its own `store_options/0`, which returns a keyword list of table options.
All stores **_MUST_** implement its own `store_options/0`, which returns a keyword list of store options.

There are three optional callbacks which can be implemented:

- `init_store/0`, which allows users to implement custom table initialisation logic.
- `copy_store/0`, which allows users to implement a custom call to copy a store.
- `resolve_conflict/1`, which allows a user to implement logic when table data is found on both the remote node and local node when connecting to a cluster. This currently has no default implementation.
- `init_store/0`, which allows users to implement custom store initialization logic. Triggered by Mnesiac.
- `copy_store/0`, which allows users to implement a custom call to copy a store. Triggered by Mnesiac.
- `resolve_conflict/1`, which allows a user to implement logic when Mnesiac detects a store with records on both the local and remote Mnesia cluster node. Triggered by Mnesiac. Default is to do nothing.

**_MINIMAL EXAMPLE:_**:

```elixir
defmodule MyApp.ExampleStore do
@moduledoc false
require Record
@moduledoc """
Provides the structure of ExampleStore records for a minimal example of Mnesiac.
"""
use Mnesiac.Store
import Record, only: [defrecord: 3]

@doc """
Record definition for ExampleStore example record.
"""
Record.defrecord(
:example,
__MODULE__,
Expand All @@ -95,6 +104,9 @@ defmodule MyApp.ExampleStore do
event: nil
)

@typedoc """
ExampleStore example record field type definitions.
"""
@type example ::
record(
:example,
Expand All @@ -106,6 +118,7 @@ defmodule MyApp.ExampleStore do
@impl true
def store_options,
do: [
record_name: __MODULE__,
attributes: example() |> example() |> Keyword.keys(),
index: [:topic_id],
ram_copies: [node()]
Expand All @@ -115,15 +128,15 @@ end

### Clustering

If you are using `libcluster` or another clustering library just ensure that clustering library starts earlier than `mnesiac`. That's all, you don't need to do anything else.
If you are using `libcluster` or another clustering library, ensure that the clustering library starts before `mnesiac`. That's all, you don't need to do anything else.

If you are not using `libcluster` or similar clustering library then:
If you are not using `libcluster` or similar clustering libraries then:

- When a node joins to an erlang/elixir cluster, run the `Mnesiac.init_mnesia()` function on the *new node*. This will initialize and copy table contents from the other online nodes.
- When a node joins to an erlang/elixir cluster, run the `Mnesiac.init_mnesia/1` function on the **_new node_**. This will initialize and copy the store contents from the other online nodes in the Mnesia cluster.

## Development

Ensure you have the proper language versions installed. To do this, an `asdf` tools file is provided. Run the following:
Ensure you have the proper language versions installed. To do this, an `asdf` tools file has been provided. Run the following:

```shell
git clone https://github.com/beardedeagle/mnesiac.git
Expand All @@ -134,14 +147,13 @@ mix local.rebar --force
mix deps.get --force
mix deps.compile --force
mix compile --force
mix check
```

**_NOTICE:_** You can find the `asdf` tool [here][1].

## Testing

Before you run any tests, ensure that you have cleaned up mnesia:
Before you run any tests, ensure that you have cleaned up Mnesia:

```shell
mix purge.db
Expand Down
13 changes: 8 additions & 5 deletions config/.credo.exs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
included: ["lib/", "src/", "test/", "web/", "apps/", "config/"],
excluded: [~r"/_build/", ~r"/deps/", ~r"/node_modules/"]
},
plugins: [],
requires: [],
strict: true,
color: true,
Expand Down Expand Up @@ -36,6 +37,7 @@
{Credo.Check.Readability.StringSigils, []},
{Credo.Check.Readability.TrailingBlankLine, []},
{Credo.Check.Readability.TrailingWhiteSpace, []},
{Credo.Check.Readability.UnnecessaryAliasExpansion, false},
{Credo.Check.Readability.VariableNames, []},
{Credo.Check.Refactor.CondStatements, []},
{Credo.Check.Refactor.CyclomaticComplexity, []},
Expand All @@ -46,12 +48,8 @@
{Credo.Check.Refactor.NegatedConditionsInUnless, []},
{Credo.Check.Refactor.NegatedConditionsWithElse, []},
{Credo.Check.Refactor.Nesting, []},
{Credo.Check.Refactor.PipeChainStart,
[
excluded_argument_types: [:atom, :binary, :fn, :keyword, :number],
excluded_functions: []
]},
{Credo.Check.Refactor.UnlessWithElse, []},
{Credo.Check.Refactor.WithClauses, []},
{Credo.Check.Warning.BoolOperationOnSameValues, []},
{Credo.Check.Warning.ExpensiveEmptyEnumCheck, []},
{Credo.Check.Warning.IExPry, []},
Expand All @@ -69,12 +67,17 @@
{Credo.Check.Warning.UnusedStringOperation, []},
{Credo.Check.Warning.UnusedTupleOperation, []},
{Credo.Check.Consistency.MultiAliasImportRequireUse, false},
{Credo.Check.Consistency.UnusedVariableNames, false},
{Credo.Check.Design.DuplicatedCode, false},
{Credo.Check.Readability.AliasAs, false},
{Credo.Check.Readability.MultiAlias, false},
{Credo.Check.Readability.Specs, false},
{Credo.Check.Readability.SinglePipe, false},
{Credo.Check.Refactor.ABCSize, false},
{Credo.Check.Refactor.AppendSingleItem, false},
{Credo.Check.Refactor.DoubleBooleanNegation, false},
{Credo.Check.Refactor.ModuleDependencies, false},
{Credo.Check.Refactor.PipeChainStart, false},
{Credo.Check.Refactor.VariableRebinding, false},
{Credo.Check.Warning.MapGetUnsafePass, false},
{Credo.Check.Warning.UnsafeToAtom, false}
Expand Down
3 changes: 2 additions & 1 deletion coveralls.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"coverage_options": {
"treat_no_relevant_lines_as_covered": true
"treat_no_relevant_lines_as_covered": true,
"minimum_coverage": 80
},
"skip_files": [
"test/support"
Expand Down
1 change: 1 addition & 0 deletions lib/mnesiac/store_manager.ex
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ defmodule Mnesiac.StoreManager do

Enum.each(stores(), fn data_mapper ->
cookie = Keyword.get(data_mapper.store_options(), :record_name, data_mapper)

case {local_cookies[cookie], remote_cookies[cookie]} do
{nil, nil} ->
apply(data_mapper, :init_store, [])
Expand Down
21 changes: 13 additions & 8 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ defmodule Mnesiac.MixProject do
def project do
[
app: :mnesiac,
version: "0.3.3",
version: "0.3.4",
elixir: "~> 1.7",
elixirc_paths: elixirc_paths(Mix.env()),
test_coverage: [tool: ExCoveralls],
Expand All @@ -31,7 +31,7 @@ defmodule Mnesiac.MixProject do
build_embedded: Mix.env() == :prod,
start_permanent: Mix.env() == :prod,
package: [
description: "Autoclustering for mnesia made easy!",
description: "Auto clustering for Mnesia made easy!",
files: ["lib", ".formatter.exs", "mix.exs", "README.md", "LICENSE", "CHANGELOG.md"],
maintainers: ["beardedeagle"],
licenses: ["MIT"],
Expand All @@ -43,7 +43,12 @@ defmodule Mnesiac.MixProject do
formatters: ["html", "epub"]
],
aliases: [
check: ["format", "compile --force", "credo --strict --all", "inch"],
check: [
"format --check-formatted --dry-run",
"compile --warning-as-errors --force",
"credo --strict --all",
"inch"
],
"purge.db": &purge_db/1
],
name: "Mnesiac",
Expand All @@ -63,12 +68,12 @@ defmodule Mnesiac.MixProject do

defp deps do
[
{:libcluster, "~> 3.0", optional: true},
{:credo, "~> 1.0", only: [:dev], runtime: false},
{:libcluster, "~> 3.1", optional: true},
{:credo, "~> 1.1", only: [:dev], runtime: false},
{:dialyxir, "~> 1.0.0-rc", only: [:dev], runtime: false},
{:ex_doc, "~> 0.19", only: [:dev], runtime: false},
{:ex_unit_clustered_case, "~> 0.3", only: [:dev, :test]},
{:excoveralls, "~> 0.10", only: [:dev, :test], runtime: false},
{:ex_doc, "~> 0.21", only: [:dev], runtime: false},
{:ex_unit_clustered_case, "~> 0.4", only: [:dev, :test]},
{:excoveralls, "~> 0.11", only: [:dev, :test], runtime: false},
{:inch_ex, "~> 2.0", only: [:dev], runtime: false}
]
end
Expand Down
Loading

0 comments on commit 8d8b401

Please sign in to comment.