Giter VIP home page Giter VIP logo

ex-cbsf2018's Introduction

Coins

Coins is an example app using CQRS and Event Sourcing.

It uses:

Using

Setup the databases with mix setup_db and then run iex -S mix

iex> Coins.mine_coin("me", 1)
{:error, :invalid_nonce}

iex> Coins.mine_coin("me", 190)
:ok

iex> Coins.mine_coin("me", 190)
{:error, :used_nonce}

iex> Coins.mine_coin("me", 443)
:ok

iex> Coins.richest |> Map.take([:account_id, :balance])
%{account_id: "me", balance: 1}

iex> [488, 1442, 1597] |> Enum.map(&(Coin.mine_coin("you" &1)))
[:ok, :ok, :ok]

iex> Coins.richest |> Map.take([:account_id, :balance])
%{account_id: "you", balance: 3}

iex> Coins.send_coins("you", "me", 99999)
{:error, :not_enough_coins}

iex> Coins.send_coins("you", "me", 3)
:ok

iex> Coins.richest |> Map.take([:account_id, :balance])
%{account_id: "me", balance: 5}

ex-cbsf2018's People

Contributors

bamorim avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

ex-cbsf2018's Issues

== Compilation error in file lib/coins/send_coins_process.ex ==

Hi, first of all, thank you for your repo.

But, I'm struggling with this, when I try to use mix setup_db or mix reset_db I get the following error:

ompiling 12 files (.ex)
warning: unused alias Transfer
  lib/coins.ex:6


== Compilation error in file lib/coins/send_coins_process.ex ==
** (UndefinedFunctionError) function :elixir_errors.warn/1 is undefined or private. Did you mean one of:

      * warn/3

    (elixir) :elixir_errors.warn("Commanded Deprecation Warning:\nProcessmanager Elixir.Coins.SendCoinsProcess defined error/4 callback.\nThis is deprecated in favor of error/3\nSee https://github.com/commanded/commanded/blob/master/guides/Process%20Managers.md#deprecated-error4")
    (stdlib) erl_eval.erl:677: :erl_eval.do_apply/6
    /Users/yamildiazaguirre/Documents/freelance/rideqro/ex-cbsf2018/lib/coins/send_coins_process.ex:1: Commanded.ProcessManagers.ProcessManager.__before_compile__/1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.