onyx-eda

Event-Driven Architecture framework to build reactive apps πŸ’£ shard onyxframework events event-driven
0.1.0 released
onyxframework/eda
8 2 1
Onyx Framework

Onyx::Event

Built with Crystal Travis CI build Docs API docs Latest release

An Event-Driven Architecture framework for Crystal.

About

Onyx::Event brings the Event-Driven Architecture to the Crystal Language, making it possible to build event-driven applications fast. It allows to emit events and attach subscribers (and also consumers) to these events, via multiple channels.

Features comparison

Onyx Framework is an open-core software, which ensures its long-term support and development. Purchasing a commercial license gives you a Github team membership with an access to private repositories containing extra features and also an access to private Twist team for extened support. Read more at Commercial FAQ.

Feature | Open Source (this repo) | Pro | Enterprise --- | :---: | :---: | :---: Subscribers | βœ” | βœ” | βœ” Memory channel | βœ” | βœ” | βœ” Redis channel | βœ” | βœ” | βœ” Consumers | ✘ | βœ” | βœ” Redis store | ✘ | βœ” | βœ” DB store | ✘ | βœ” | βœ” Kafka channel | ✘ | ✘ | βœ” RabbitMQ channel | ✘ | ✘ | βœ” On-demand custom channels | ✘ | ✘ | βœ” On-demand custom stores | ✘ | ✘ | βœ” License | BSD 3-Clause | Commercial | Custom Price | Free | ~~$100~~ $50/month* | Contact us

* A 50% discount is applicable until version 1.0 of this software.

Installation

Add this to your application's shard.yml:

dependencies:
+   onyx-event:
+     github: onyxframework/event
+     version: ~> 0.0.1

This shard follows Semantic Versioning v2.0.0, so check releases and change the version accordingly. Please visit github.com/crystal-lang/shards to know more about Crystal shards.

Usage

Documentation

For a deeper information on usage, please visit:

Example

First of all, define some events for your application:

require "onyx-event"

struct MyEvent < Onyx::Event
  getter foo

  def initialize(@foo : String)
  end
end

event.cr

Then define an event generator:

require "onyx-event/channel/redis"
require "./event"

channel = Onyx::Event::Channel::Redis.new

loop do
  sleep(1)
  channel.send(MyEvent.new(Time.now.to_s))
  puts "Sent MyEvent"
end

generator.cr

And a consumer:

require "onyx-event/channel/redis"
require "./event"

channel = Onyx::Event::Channel::Redis.new

channel.subscribe(MyEvent) do |event|
  puts "Got #{typeof(event)}: #{event.foo}"
end

sleep

consumer.cr

Then launch the generator and arbitrary amount of consumers:

$ crystal generator.cr
Sent MyEvent
Sent MyEvent
$ crystal consumer.cr
Got MyEvent: 2019-01-09 17:20:10 +03:00
Got MyEvent: 2019-01-09 17:20:11 +03:00

Contributing

  1. Fork it (https://github.com/onyxframework/rest/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'feat: new feature') using angular-style commits
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Licensing

This software is licensed under BSD 3-Clause License.

Open Source Initiative

onyx-eda:
  github: onyxframework/eda
  version: ~> 0.1.0
License MIT
Crystal 0.27.0

Authors

Dependencies 1

  • msgpack ~> 0.14.2
    {'github' => 'crystal-community/msgpack-crystal', 'version' => '~> 0.14.2'}

Development Dependencies 1

  • redis ~> 2.1.1
    {'github' => 'stefanwille/crystal-redis', 'version' => '~> 2.1.1'}

Dependents 1

Last synced .
search fire star recently