Event-Driven Architecture framework
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
spec
src
.editorconfig
.gitignore
.travis.yml
LICENSE
README.md
shard.yml

README.md

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