Steemex v0.13 released: improved reliability and convenience [open source Elixir library for Steem]
This release includes improvements and bugfixes I've made over the past few months. Noteworthy changes: 1) erlang websockets client library was replaced by elixir websockex package 2) jsonrpc responses are parsed to native datatypes for elixir, for example, NaiveDateTime for timestamp.
Repos and docs
GenStage event producers
Steemex uses GenStage, a new specification for handling and exchanging events among Elixir/Erlang processes.
On module app startup two GenStage processes are started and registered:
Steemex.Stage.Blocks.Producer which, perhaps unsurprisingly, is a new blocks producer
Steemex.Stage.RawOps produces raw blockchain operations
Steemex.Stage.MungedOps produces parsed, cleaned and transformed operations
A GenStage consumer example
defmodule Steemex.Stage.ExampleConsumer do
use GenStage
alias Steemex.MungedOps
require Logger
def start_link(args, options \\ []) do
GenStage.start_link(__MODULE__, args, options)
end
def init(state) do
Logger.info("Example consumer is initializing...")
{:consumer, state, subscribe_to: state[:subscribe_to]}
end
def handle_events(events, _from, state) do
for op <- events do
process_event(op)
end
{:noreply, [], state}
end
def process_event(%{data: %MungedOps.Reblog{} = data, metadata: %{height: h, timestamp: t} = metadata}) do
Logger.info """
New reblog:
#{inspect data}
with metadata
#{inspect metadata}
"""
end
def process_event(%{data: data, metadata: %{block_height: h, timestamp: t} = metadata}) do
Logger.info """
New operation:
#{inspect data}
with metadata
#{inspect metadata}
"""
end
end
Roadmap
- Add latest blockchain ops
- Add more structured ops and transformations
- Add transaction broadcast
About Elixir
Elixir is a functional programming language with superior concurrency primitives, distributed computation and fault tolerance capabilities based on Erlang/OTP.
Personally, I am really happy with my bet on Elixir to build cryptotokens related apps and strongly recommend every developer to try it.
Learning resources:
- ElixirConf Jose Valim Keynote
- ElixirConf 2016 Chris McCord Keynote
- Elixir School
- Elixir Crash Course
Great work 👍💪
Wow nice changes and good improvement ,,great job keep it up
You also follow ,upvote and comment @horlly
i up vote you sir please up vote me on @iwant because your vote give me a way to survive on steemit thanks & iwill always upvote you