Project

raes

0.0
No release in over 3 years
Low commit activity in last 3 years
Description of Rails Async Event Store.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

 Project Readme

Raes

Raes is Rails Async Event Store. Executes a class method call asynchronously. Others use Rails' Active Job and Active Storage services to store files.

  • Raes (※)

rice

Usage

Dispatch a class name that has a call method.

Simple Echo

Same echo call method.

class SimpleEcho
  include Raes::UseCaller

  def initialize(params)
    @params = params
  end

  def call
    @params
  end
end

When executed, { message:'Hi' } is saved in state.

Raes.dispatch(SimpleEcho, { message: 'Hi' })
Raes.search(SimpleEcho).last.state # "{\"message\":\"Hi\"}"

File Maker

Rewrite old file newly.

class FileMaker
  include Raes::UseCaller
  include Raes::UseStorage

  def initialize(params)
    @raes_storage_id = params[:raes_storage_id]
  end

  def call
    old_file = raes_storage_content
    new_file = old_file + 'bar'

    raes_storage_attach({ io: StringIO.new(new_file), filename: 'new_file.txt', content_type: 'text/plain' })
  end
end

Content will be changed to the new file.

Raes.dispatch(FileMaker, raes_storage: { io: StringIO.new('foo'), filename: 'old_file.txt', content_type: 'text/plain' })
Raes.search(FileMaker).last.storages.first.content.download # foobar

Installation

Add this line to your application's Gemfile:

gem 'raes'

And then execute:

$ bundle
$ rails raes:install:migrations

If use storage, then execute:

$ rails active_storage:install

Configuration

Add the following to your config/raes.yml:

default: &default
  concern:
    context_logger: Rails

development:
  <<: *default

test:
  <<: *default

production:
  <<: *default

Test

$ rails app:spec

License

The gem is available as open source under the terms of the MIT License.