Steemex v0.10 released: GenStage blockchain event producers [open source Elixir library for Steem]
This releases adds GenStage event producers, a composable abstraction for consuming data from third-party systems and a behaviour for exchanging events with back-pressure between Elixir processes. GenStage integration makes Steemex usage simpler and easier: just start a GenStage Consumer with a following option:
subscribe_to: Steemex.Stage.Blocks.Producer
or subscribe_to: Steemex.Stage.Ops.ProducerConsumer
. Both producers use BroadcastDispatcher -- every blockchain event will be broadcasted to all subscribed consumers.
GenStage is a great tool for blockchain related tasks and I'm nearly certain that GenStage is here to stay for a long time.
Repos and docs
Changelog
- breaking: previous Steemex.Streamer module was removed
stream_to
config option was removed- new
Steemex.Stage.Blocks.Producer
module - new
Steemex.Stage.Ops.ProducerConsumer
module - new supervisor module for GenStage producers
- basic example of GenStage consumer for steem operation events
- updated readme
A GenStage consumer example
defmodule Steemex.Stage.Ops.ExampleConsumer do
use GenStage
require Logger
def start_link(args, options \\ []) do
GenStage.start_link(__MODULE__, args, options)
end
def init(state) do
{:consumer, state, subscribe_to: state.subscribe_to}
end
def handle_events(events, _from, state) do
for op <- events do
Logger.info """
New operation:
#{inspect op}
"""
end
{:noreply, [], state}
end
end
Roadmap
Investigate using GenStage- Add more utility functions
- Add more types and structs
- 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
Very cool, keep up the great work! :)
thanks, @cm-steem! :)
Will this be used in future glasnost releases?
Yep, absolutely :)
Excellent, can't wait! :D
Nice one :) I wasn't aware of that project so far -> Followed.
I don't understand this at all but it sounds interesting!!