create account

Steemex v0.11 released: now with producer of structured operations [open source Elixir library for Steem] by ontofractal

View this thread on: hive.blogpeakd.comecency.com
· @ontofractal · (edited)
$568.39
Steemex v0.11 released: now with producer of structured operations [open source Elixir library for Steem]
<center>![](http://i.imgur.com/QKOa4iu.png)</center>
My goal for this release was to significantly simplify handling of blockchain event streams by extracting custom ops into their own structs, parsing values out of strings and adding block metadata. As one example, you can now pattern match against reblog or follows.

Structured ops event producer follows [GenStage](http://elixir-lang.org/blog/2016/07/14/announcing-genstage/) spec which allows you to easily patch into the transformation pipeline at any step: block producer, ops producer or structured ops producer.


# Repos and docs

* [github](https://github.com/cyberpunk-ventures/steemex)
* [hex.pm](https://hex.pm/packages/steemex)
* [docs](https://hexdocs.pm/steemex)


# Changelog

* added `Steemex.Stage.StructuredOps.ProducerConsumer` module 
* To susbcribe use the following GenStage option: `subscribe_to: Steemex.Stage.StructuredOps.ProducerConsumer`. All producers use BroadcastDispatcher -- blockchain event wills be sent to all subscribed consumers.
* added multiple structured ops structs
* added multiple transformation functions and tests for each
* event shape of structured ops producer has changed to `{op_data, op_metadata}` where op_data can be matched against ops structs
* event shape of ops producer has been changed to `{op_type, op_data, op_metadata}`
* transfer value strings are now parsed into operation struct fields  
* tags, app fields are added to structured comment struct
* op_metadata is now available with `%{height: h, timestamp: t}` fields
* updated supervisor module for GenStage producers 
* updated example of GenStage consumer for structured steem operation with pattern matching on structs and metadata

## A GenStage consumer example

```
defmodule Steemex.StructuredStage.Ops.ExampleConsumer do
  use GenStage
  alias Steemex.StructuredOps
  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
      process_event(op)
    end
    {:noreply, [], state}
  end

  def process_event({%StructuredOps.Reblog{} = op_data, %{height: h, timestamp: t} =  op_metadata}) do
      Logger.info """
      New reblog:
      #{inspect op_data} at height #{h} and time #{t}
      """
  end

  def process_event({op_data, %{height: h, timestamp: t} =  op_metadata}) do
      Logger.info """
      New operation:
      #{inspect op_data} at height #{h} and time #{t}
      """
  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](http://confreaks.tv/videos/elixirconf2016-keynote)
* [ElixirConf 2016 Chris McCord Keynote](http://confreaks.tv/videos/elixirconf2016-keynote)
* [Elixir School](https://elixirschool.com/)
* [Elixir Crash Course](http://elixir-lang.org/crash-course.html)

<center>(∩^o^)⊃━☆゜.*</center>
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 82 others
properties (23)
authorontofractal
permlinksteemex-v0-11-released-now-with-producer-of-structured-operations-open-source-elixir-library-for-steem
categorysteemdev
json_metadata{"tags":["steemdev","steem","open-source","steemstem","steem-dev"],"image":["http://i.imgur.com/QKOa4iu.png"],"links":["http://elixir-lang.org/blog/2016/07/14/announcing-genstage/","https://github.com/cyberpunk-ventures/steemex","https://hex.pm/packages/steemex","https://hexdocs.pm/steemex","http://confreaks.tv/videos/elixirconf2016-keynote","https://elixirschool.com/","http://elixir-lang.org/crash-course.html"],"app":"steemit/0.1","format":"markdown"}
created2017-06-07 19:14:54
last_update2017-06-08 08:18:03
depth0
children5
last_payout2017-06-14 19:14:54
cashout_time1969-12-31 23:59:59
total_payout_value452.820 HBD
curator_payout_value115.567 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length3,365
author_reputation61,670,850,962,884
root_title"Steemex v0.11 released: now with producer of structured operations [open source Elixir library for Steem]"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id4,355,901
net_rshares23,815,255,385,791
author_curate_reward""
vote details (146)
@ijoel ·
yours is very benefits to me
properties (22)
authorijoel
permlinkre-ontofractal-steemex-v0-11-released-now-with-producer-of-structured-operations-open-source-elixir-library-for-steem-20170612t121424224z
categorysteemdev
json_metadata{"tags":["steemdev"],"app":"steemit/0.1"}
created2017-06-12 12:14:33
last_update2017-06-12 12:14:33
depth1
children0
last_payout2017-06-19 12:14:33
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length28
author_reputation12,761,279,731,286
root_title"Steemex v0.11 released: now with producer of structured operations [open source Elixir library for Steem]"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id4,653,958
net_rshares0
@leviathanfisher ·
Do what?
properties (22)
authorleviathanfisher
permlinkre-ontofractal-steemex-v0-11-released-now-with-producer-of-structured-operations-open-source-elixir-library-for-steem-20180830t083621261z
categorysteemdev
json_metadata{"tags":["steemdev"],"app":"steemit/0.1"}
created2018-08-30 08:36:21
last_update2018-08-30 08:36:21
depth1
children0
last_payout2018-09-06 08:36:21
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length8
author_reputation164,296,470,172
root_title"Steemex v0.11 released: now with producer of structured operations [open source Elixir library for Steem]"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id69,776,789
net_rshares0
@nirmal ·
Seems Good :)
👍  
properties (23)
authornirmal
permlinkre-ontofractal-steemex-v0-11-released-now-with-producer-of-structured-operations-open-source-elixir-library-for-steem-20170607t202111212z
categorysteemdev
json_metadata{"tags":["steemdev"],"app":"steemit/0.1"}
created2017-06-07 20:21:12
last_update2017-06-07 20:21:12
depth1
children0
last_payout2017-06-14 20:21:12
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length13
author_reputation1,065,719,594,079
root_title"Steemex v0.11 released: now with producer of structured operations [open source Elixir library for Steem]"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id4,359,315
net_rshares360,898,972
author_curate_reward""
vote details (1)
@randowhale ·
This post received a 78% upvote from @randowhale thanks to @jesta!  For more information on @randowhale [click here](https://steemit.com/steemit/@randowhale/introducing-randowhale-will-you-get-the-100-vote-give-it-a-shot)!
properties (22)
authorrandowhale
permlinkre-steemex-v0-11-released-now-with-producer-of-structured-operations-open-source-elixir-library-for-steem-20170608t054350
categorysteemdev
json_metadata"{"format": "markdown", "app": "randowhale/0.1"}"
created2017-06-08 05:43:51
last_update2017-06-08 05:43:51
depth1
children0
last_payout2017-06-15 05:43:51
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length222
author_reputation47,657,457,485,459
root_title"Steemex v0.11 released: now with producer of structured operations [open source Elixir library for Steem]"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id4,384,103
net_rshares0
@tensorflow ·
Hello, I'm  interested in elixir language, can you please tag posts related to elixir?

Also, I wonder what environment do you use to write code/test program in elixir?
properties (22)
authortensorflow
permlinkre-ontofractal-steemex-v0-11-released-now-with-producer-of-structured-operations-open-source-elixir-library-for-steem-20170610t174201037z
categorysteemdev
json_metadata{"tags":["steemdev"],"app":"steemit/0.1"}
created2017-06-10 17:42:00
last_update2017-06-10 17:42:00
depth1
children0
last_payout2017-06-17 17:42:00
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length168
author_reputation1,359,801,546,368
root_title"Steemex v0.11 released: now with producer of structured operations [open source Elixir library for Steem]"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id4,543,649
net_rshares0