Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Add Mix Install/Docs, Start/Stop ABCI Server guides #3

Closed
wants to merge 6 commits into from
93 changes: 93 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,103 @@

An Erlang application that allows writing [Application Blockchain Interface](https://github.com/tendermint/abci) servers.

ABCI Server with Erlang bindings is used by the [Tendermint Ecosystem](http://tendermint.readthedocs.io/projects/tools/en/master/ecosystem.html#abci-servers)

This application uses [semantic versioning 2.0](http://semver.org/).

[erlang.mk](https://erlang.mk/) is used as a build tool.

## Installation with Mix and Usage in Interactive Elixir (IEx)

* Add ABCI Server (Erlang) to mix.exs. [Choose a Release Tag](https://github.com/KrzysiekJ/abci_server/tags)
```elixir
defp deps do
[
# ABCI Server (Erlang) - https://github.com/KrzysiekJ/abci_server
{:abci_server, git: "https://github.com/KrzysiekJ/abci_server.git", tag: "v0.4.0"}
]
end
```

* Install Mix Dependencies
```bash
mix deps.get
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a generic Elixir command, no need to put it here.

```

* Documentation Generation. Open Documentation in Web Browser
```bash
cd deps/abci_server/ && make docs && open doc/index.html && cd ../../
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is already covered in the “Documentation” section.

```

* Run IEx
```bash
iex -S mix
```

* Create a Fake Module named Foo
```
iex(1)> defmodule Foo do
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This module doesn’t implement the abci_app behaviour, so it won’t be able to handle ABCI requests.

...(1)> def bar() do
...(1)> IO.puts("You're using ABCI Server!")
...(1)> end
...(1)> end
{:module, Foo,
<<70, ..., 117, ...>>, {:bar, 0}}
```

* Show ABCI Server Information (using `module_info/1` which is the Erlang equivalent of Elixir's `__info__/1`), Start ABCI Server, Stop ABCI Server
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a generic Erlang function. I don’t see much utility in putting information about this in README.

```
iex(3)> :abci_server.module_info
[
module: :abci_server,
exports: [
start_link: 4,
start_listener: 2,
...
],
attributes: [
...
behaviour: [:gen_server],
behaviour: [:ranch_protocol]
],
compile: [
...
],
native: false,
md5: <<65, ..., 206>>
]
```

* Run the ABCI Server's `start_listener` and `stop_listener` functions
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is already written in doc/overview.edoc (though for Erlang).

```
iex> {ok, _} = :abci_server.start_listener(Foo, 46658)
{:ok, #PID<0.181.0>}

iex> ok = :abci_server.stop_listener(Foo)
:ok
```

* Test the Running ABCI Server (Erlang) in separate Bash Terminal Tab - https://github.com/tendermint/abci#tools
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is Tendermint-related documentation, no need to duplicate it here.

```
abci-cli test
```

## Troubleshooting

If when running IEX you get error `(Mix) Could not start application ranch: could not find application file: ranch.app` then a possible solution is to install Ranch 1.4.0.
* Remove existing Mix dependencies
```bash
rm -rf deps
```
* Adding Ranch 1.4.0 to the mix.exs file of your Mix project.
```elixir
{:ranch, git: "https://github.com/ninenines/ranch.git", tag: "1.4.0"}
```
* Install Mix Dependencies
```bash
mix deps.get
```

## Documentation

Run `make docs` and open `doc/index.html`.
Expand Down