Skip to content

Commit

Permalink
Don't use module attribute for configuration values since they are se…
Browse files Browse the repository at this point in the history
…t on compilation time.
  • Loading branch information
Ole Spaarmann committed Jun 21, 2018
1 parent bcb70f7 commit 8d7afff
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
6 changes: 5 additions & 1 deletion Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

## [0.2.0-alpha.5] - 2018-06-21
### Fixed
- Don't use module attribute for configuration values since they are set on compilation time. This prevented the enforce_struct_schema feature to work properly.

## [0.2.0-alpha.4] - 2018-06-21
### Added
- New function `set_struct/2`. This function allow you to convert an struct type into a mutation (json based) type in dgraph. It also allows you to enforce the schema in database (adding a "class name" info before every predicate, this class name is the single name given to the elixir module struct) by activating the `enforce_struct_schema` in the config files. The function sends the mutation to the server and returns `{:ok, result}` or `{:error, error}` otherwise. Internally it uses Dgraphs `set_json`. Thanks to @WolfDan.
- New config option `keepalive`. It defines the time in ms between pings to the server. Default value is `:infinity` which disables pings completely. Dgraph drops the connection on pings at the moment so it is disabled for now. Internally this uses `:adapter_opts` of grpc-elixir which in turn sets `http2_opts` of gun.
- I added a changelog.

## Fixed
### Fixed
- The `keepalive` option fixes the `gun_down` error for now. The connection was dropped by Dgraph when the server was pinged. The server sent a `{goaway,0,enhance_your_calm,<<"too_many_pings">>}` message. For now pings are disabled. This is not ideal since this way ExDgraph cannot check if the connection is still alive. But I have to wait for Dgraph to get back to me on this issue. You find the issue here: https://github.com/dgraph-io/dgraph/issues/2444
- Removed some warnings and refactored a couple of things.
4 changes: 1 addition & 3 deletions lib/exdgraph/mutation.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ defmodule ExDgraph.Mutation do
"""
alias ExDgraph.{Exception, MutationStatement, Transform}

@enforce_struct_schema Application.get_env(:ex_dgraph, ExDgraph)[:enforce_struct_schema]

@doc false
def mutation!(conn, statement) do
case mutation_commit(conn, statement) do
Expand Down Expand Up @@ -152,7 +150,7 @@ defmodule ExDgraph.Mutation do
existing_uuid -> existing_uuid
end)
|> Enum.reduce(%{}, fn {key, map_value}, a ->
set_schema(schema, {key, map_value}, a, @enforce_struct_schema)
set_schema(schema, {key, map_value}, a, ExDgraph.config(:enforce_struct_schema))
end)
end

Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule ExDgraph.MixProject do
def project do
[
app: :ex_dgraph,
version: "0.2.0-alpha.4",
version: "0.2.0-alpha.5",
elixir: "~> 1.6",
start_permanent: Mix.env() == :prod,
deps: deps(),
Expand Down

0 comments on commit 8d7afff

Please sign in to comment.