laterbox 0.0.0.alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/README.md +25 -0
- data/Rakefile +8 -0
- data/exe/laterbox +14 -0
- data/laterbox.gemspec +40 -0
- data/lib/laterbox/bootloader.rb +11 -0
- data/lib/laterbox/command.rb +84 -0
- data/lib/laterbox/config.rb +64 -0
- data/lib/laterbox/version.rb +12 -0
- data/lib/laterbox.rb +10 -0
- data/sig/laterbox +4 -0
- metadata +100 -0
    
        checksums.yaml
    ADDED
    
    | @@ -0,0 +1,7 @@ | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            SHA256:
         | 
| 3 | 
            +
              metadata.gz: d72734a944f185b6651c5edb64c655b4f364dc5a5653aa3b399c5ef3f7c4d701
         | 
| 4 | 
            +
              data.tar.gz: fcbf6d42c2b28114fb0b8f984def77d87317fbd02665e298473d5e6649bdaecc
         | 
| 5 | 
            +
            SHA512:
         | 
| 6 | 
            +
              metadata.gz: 93651564b4be33f872fca5f33e438bb2bcf24c8d6b51f343411febaa48575cbdda31db86acfc5328a3a6dbd7a9c9207e4205169e227b4ab4e7c2741485606c82
         | 
| 7 | 
            +
              data.tar.gz: 2fed57a9d2c47d7a2f8a515af39a6ecafd739a93654dc69d2fef60fca5c6647448d2637584e8c448d4bc1191bc786beb87a3477867c54e0405a066d76c12e920
         | 
    
        data/README.md
    ADDED
    
    | @@ -0,0 +1,25 @@ | |
| 1 | 
            +
            # Laterbox
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            ## Installation
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            Install the gem and add to the application's Gemfile by executing:
         | 
| 6 | 
            +
             | 
| 7 | 
            +
                $ bundle add UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            If bundler is not being used to manage dependencies, install the gem by executing:
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                $ gem install UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            ## Usage
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            TODO: Write usage instructions here
         | 
| 16 | 
            +
             | 
| 17 | 
            +
            ## Development
         | 
| 18 | 
            +
             | 
| 19 | 
            +
            After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
         | 
| 20 | 
            +
             | 
| 21 | 
            +
            To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
         | 
| 22 | 
            +
             | 
| 23 | 
            +
            ## Contributing
         | 
| 24 | 
            +
             | 
| 25 | 
            +
            Bug reports and pull requests are welcome on GitHub at https://github.com/ryancyq/laterbox.
         | 
    
        data/Rakefile
    ADDED
    
    
    
        data/exe/laterbox
    ADDED
    
    
    
        data/laterbox.gemspec
    ADDED
    
    | @@ -0,0 +1,40 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            require_relative "lib/laterbox/version"
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            Gem::Specification.new do |spec|
         | 
| 6 | 
            +
              spec.name = "laterbox"
         | 
| 7 | 
            +
              spec.version = Laterbox::VERSION::STRING
         | 
| 8 | 
            +
              spec.authors = ["Ryan Chang"]
         | 
| 9 | 
            +
              spec.email = ["ryancyq@gmail.com"]
         | 
| 10 | 
            +
             | 
| 11 | 
            +
              spec.summary = "A transactional outbox implementation for event publishing in Ruby."
         | 
| 12 | 
            +
              spec.description = "A transactional outbox implementation for event publishing in Ruby."
         | 
| 13 | 
            +
              spec.homepage = "https://github.com/ryancyq/laterbox"
         | 
| 14 | 
            +
              spec.required_ruby_version = ">= 3.0.0"
         | 
| 15 | 
            +
             | 
| 16 | 
            +
              spec.metadata["allowed_push_host"] = "https://rubygems.org"
         | 
| 17 | 
            +
              spec.metadata["homepage_uri"] = spec.homepage
         | 
| 18 | 
            +
              spec.metadata["source_code_uri"] = "https://github.com/ryancyq/laterbox"
         | 
| 19 | 
            +
              spec.metadata["changelog_uri"] = "https://github.com/ryancyq/laterbox/blob/main/CHANGELOG.md"
         | 
| 20 | 
            +
              spec.metadata["github_repo"] = "ssh://github.com/ryancyq/laterbox"
         | 
| 21 | 
            +
             | 
| 22 | 
            +
              # Specify which files should be added to the gem when it is released.
         | 
| 23 | 
            +
              # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
         | 
| 24 | 
            +
              spec.files = Dir.chdir(__dir__) do
         | 
| 25 | 
            +
                `git ls-files -z`.split("\x0").reject do |f|
         | 
| 26 | 
            +
                  (File.expand_path(f) == __FILE__) ||
         | 
| 27 | 
            +
                    f.start_with?(*%w[bin/ examples/ test/ spec/ features/ .git appveyor Gemfile])
         | 
| 28 | 
            +
                end
         | 
| 29 | 
            +
              end
         | 
| 30 | 
            +
              spec.bindir = "exe"
         | 
| 31 | 
            +
              spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
         | 
| 32 | 
            +
              spec.require_paths = ["lib"]
         | 
| 33 | 
            +
             | 
| 34 | 
            +
              spec.add_development_dependency 'rake'
         | 
| 35 | 
            +
              spec.add_development_dependency 'rspec'
         | 
| 36 | 
            +
              spec.add_development_dependency 'rubocop'
         | 
| 37 | 
            +
             | 
| 38 | 
            +
              # For more information and examples about making a new gem, check out our
         | 
| 39 | 
            +
              # guide at: https://bundler.io/guides/creating_gem.html
         | 
| 40 | 
            +
            end
         | 
| @@ -0,0 +1,84 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            $stdout.sync = true
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            require "optparse"
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            module Laterbox
         | 
| 8 | 
            +
              class Command
         | 
| 9 | 
            +
                INTERRUPT_SIGNALS = %w[INT TERM]
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                def self.run(args = ARGV.dup)
         | 
| 12 | 
            +
                  new(args).run
         | 
| 13 | 
            +
                end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                def initialize(args)
         | 
| 16 | 
            +
                  @action = options_parser.parse!(args)
         | 
| 17 | 
            +
                end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                def run
         | 
| 20 | 
            +
                  config = setup_config
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                  INTERRUPT_SIGNALS.each do |signal|
         | 
| 23 | 
            +
                    Signal.trap(signal) do
         | 
| 24 | 
            +
                      puts "Exiting due to #{signal}"
         | 
| 25 | 
            +
                    end
         | 
| 26 | 
            +
                  end
         | 
| 27 | 
            +
             | 
| 28 | 
            +
                  app = ::Laterbox::Bootloader.new(config)
         | 
| 29 | 
            +
                  app.start
         | 
| 30 | 
            +
                end
         | 
| 31 | 
            +
             | 
| 32 | 
            +
            private
         | 
| 33 | 
            +
             | 
| 34 | 
            +
                def setup_config
         | 
| 35 | 
            +
                  config = ::Laterbox::Config.new.to_hash
         | 
| 36 | 
            +
             | 
| 37 | 
            +
                  if @config_file
         | 
| 38 | 
            +
                    config.merge!(file_config(@config_file)) 
         | 
| 39 | 
            +
                  else
         | 
| 40 | 
            +
                    default_config_file = File.join("config", "laterbox.yml")
         | 
| 41 | 
            +
                    config.merge!(file_config(default_config_file)) if File.exist?(default_config_file)
         | 
| 42 | 
            +
                  end
         | 
| 43 | 
            +
                  config.merge!(command_config)
         | 
| 44 | 
            +
                  config
         | 
| 45 | 
            +
                end
         | 
| 46 | 
            +
             | 
| 47 | 
            +
                def file_config(path)
         | 
| 48 | 
            +
                  return {} unless File.exist?(path)
         | 
| 49 | 
            +
             | 
| 50 | 
            +
                  ::Laterbox::Config.from_file(path).to_hash 
         | 
| 51 | 
            +
                end
         | 
| 52 | 
            +
             | 
| 53 | 
            +
                def command_config
         | 
| 54 | 
            +
                  {
         | 
| 55 | 
            +
                    boxes: @box_names,
         | 
| 56 | 
            +
                    concurrency: @concurrency
         | 
| 57 | 
            +
                  }.compact
         | 
| 58 | 
            +
                end
         | 
| 59 | 
            +
             | 
| 60 | 
            +
                def options_parser
         | 
| 61 | 
            +
                  @options_parser ||= OptionParser.new do |opt|
         | 
| 62 | 
            +
                    opt.banner = "Usage: laterbox [options] start|stop|restart|run"
         | 
| 63 | 
            +
                    opt.on('-h', '--help', 'show help') do
         | 
| 64 | 
            +
                      $stdout.puts opt
         | 
| 65 | 
            +
                      exit(0)
         | 
| 66 | 
            +
                    end
         | 
| 67 | 
            +
                    opt.on "-v", "--version", "print version" do |_arg|
         | 
| 68 | 
            +
                      puts "Laterbox #{Laterbox::VERSION::STRING}"
         | 
| 69 | 
            +
                      exit(0)
         | 
| 70 | 
            +
                    end
         | 
| 71 | 
            +
                    opt.on "-C", "--config PATH", "path to YAML config file" do |config_file|
         | 
| 72 | 
            +
                      raise ArgumentError.new("No such file #{config_file}") unless File.exist?(config_file)
         | 
| 73 | 
            +
                      @config_file = config_file 
         | 
| 74 | 
            +
                    end
         | 
| 75 | 
            +
                    opt.on('-c', '--concurrency=2', 'number of worker threads to spawn') do |concurrency|
         | 
| 76 | 
            +
                      @concurrency = concurrency.to_i rescue nil
         | 
| 77 | 
            +
                    end
         | 
| 78 | 
            +
                    opt.on('-b', '--box=box_name_1,box_name_2', 'specify the box names') do |box_names|
         | 
| 79 | 
            +
                      @box_names = box_names.split(',')
         | 
| 80 | 
            +
                    end
         | 
| 81 | 
            +
                  end
         | 
| 82 | 
            +
                end
         | 
| 83 | 
            +
              end
         | 
| 84 | 
            +
            end
         | 
| @@ -0,0 +1,64 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            require "yaml"
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            module Laterbox
         | 
| 6 | 
            +
              class Config
         | 
| 7 | 
            +
             | 
| 8 | 
            +
                DEFAULT_LOG_LEVEL = 'info'.freeze
         | 
| 9 | 
            +
                DEFAULT_BOXES = [].freeze
         | 
| 10 | 
            +
                DEFAULT_CONCURRENCY = 3
         | 
| 11 | 
            +
                DEFAULT_BUFFER_SIZE = 1
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                attr_accessor :default_log_level, :boxes, :concurrency, :buffer_size
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                def initialize(options = {})
         | 
| 16 | 
            +
                  set_defaults
         | 
| 17 | 
            +
                  @default_log_level = options[:default_log_level] if options.key?(:default_log_level)
         | 
| 18 | 
            +
                  @boxes             = options[:boxes] if options.key?(:boxes)
         | 
| 19 | 
            +
                  @concurrency        = options[:concurrency] if options.key?(:concurrency)
         | 
| 20 | 
            +
                  @buffer_size       = options[:buffer_size] if options.key?(:buffer_size)
         | 
| 21 | 
            +
                end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                def to_hash
         | 
| 24 | 
            +
                  {
         | 
| 25 | 
            +
                    default_log_level: @default_log_level,
         | 
| 26 | 
            +
                    boxes:             @boxes,
         | 
| 27 | 
            +
                    concurrency:       @concurrency,
         | 
| 28 | 
            +
                    buffer_size:       @buffer_size
         | 
| 29 | 
            +
                  }
         | 
| 30 | 
            +
                end
         | 
| 31 | 
            +
             | 
| 32 | 
            +
                def self.from_file(file_path)
         | 
| 33 | 
            +
                  raise ArgumentError.new("No such config file #{file_path}") unless File.exist?(file_path)
         | 
| 34 | 
            +
             | 
| 35 | 
            +
                  file_content = File.read(file_path)
         | 
| 36 | 
            +
                  options = YAML.safe_load(file_content, permitted_classes: [Symbol], aliases: true) || {}
         | 
| 37 | 
            +
                  
         | 
| 38 | 
            +
                  if options.respond_to?(:deep_symbolize_keys!)
         | 
| 39 | 
            +
                    options.deep_symbolize_keys!
         | 
| 40 | 
            +
                  else
         | 
| 41 | 
            +
                    symbolize_keys_deep!(options)
         | 
| 42 | 
            +
                  end
         | 
| 43 | 
            +
             | 
| 44 | 
            +
                  new(options)
         | 
| 45 | 
            +
                end
         | 
| 46 | 
            +
             | 
| 47 | 
            +
              private
         | 
| 48 | 
            +
             | 
| 49 | 
            +
                def set_defaults
         | 
| 50 | 
            +
                  @default_log_level = DEFAULT_LOG_LEVEL
         | 
| 51 | 
            +
                  @boxes             = DEFAULT_BOXES
         | 
| 52 | 
            +
                  @concurrency        = DEFAULT_CONCURRENCY
         | 
| 53 | 
            +
                  @buffer_size       = DEFAULT_BUFFER_SIZE
         | 
| 54 | 
            +
                end
         | 
| 55 | 
            +
             | 
| 56 | 
            +
                def symbolize_keys_deep!(hash)
         | 
| 57 | 
            +
                  hash.keys.each do |key|
         | 
| 58 | 
            +
                    symkey = key.respond_to?(:to_sym) ? key.to_sym : key
         | 
| 59 | 
            +
                    hash[symkey] = hash.delete(key)
         | 
| 60 | 
            +
                    symbolize_keys_deep!(hash[symkey]) if hash[symkey].is_a? Hash
         | 
| 61 | 
            +
                  end
         | 
| 62 | 
            +
                end
         | 
| 63 | 
            +
              end
         | 
| 64 | 
            +
            end
         | 
    
        data/lib/laterbox.rb
    ADDED
    
    
    
        data/sig/laterbox
    ADDED
    
    
    
        metadata
    ADDED
    
    | @@ -0,0 +1,100 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification
         | 
| 2 | 
            +
            name: laterbox
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            +
              version: 0.0.0.alpha
         | 
| 5 | 
            +
            platform: ruby
         | 
| 6 | 
            +
            authors:
         | 
| 7 | 
            +
            - Ryan Chang
         | 
| 8 | 
            +
            autorequire: 
         | 
| 9 | 
            +
            bindir: exe
         | 
| 10 | 
            +
            cert_chain: []
         | 
| 11 | 
            +
            date: 2023-12-20 00:00:00.000000000 Z
         | 
| 12 | 
            +
            dependencies:
         | 
| 13 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 14 | 
            +
              name: rake
         | 
| 15 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 16 | 
            +
                requirements:
         | 
| 17 | 
            +
                - - ">="
         | 
| 18 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 19 | 
            +
                    version: '0'
         | 
| 20 | 
            +
              type: :development
         | 
| 21 | 
            +
              prerelease: false
         | 
| 22 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 23 | 
            +
                requirements:
         | 
| 24 | 
            +
                - - ">="
         | 
| 25 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 26 | 
            +
                    version: '0'
         | 
| 27 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 28 | 
            +
              name: rspec
         | 
| 29 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 30 | 
            +
                requirements:
         | 
| 31 | 
            +
                - - ">="
         | 
| 32 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 33 | 
            +
                    version: '0'
         | 
| 34 | 
            +
              type: :development
         | 
| 35 | 
            +
              prerelease: false
         | 
| 36 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 37 | 
            +
                requirements:
         | 
| 38 | 
            +
                - - ">="
         | 
| 39 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 40 | 
            +
                    version: '0'
         | 
| 41 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 42 | 
            +
              name: rubocop
         | 
| 43 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 44 | 
            +
                requirements:
         | 
| 45 | 
            +
                - - ">="
         | 
| 46 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 47 | 
            +
                    version: '0'
         | 
| 48 | 
            +
              type: :development
         | 
| 49 | 
            +
              prerelease: false
         | 
| 50 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 51 | 
            +
                requirements:
         | 
| 52 | 
            +
                - - ">="
         | 
| 53 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 54 | 
            +
                    version: '0'
         | 
| 55 | 
            +
            description: A transactional outbox implementation for event publishing in Ruby.
         | 
| 56 | 
            +
            email:
         | 
| 57 | 
            +
            - ryancyq@gmail.com
         | 
| 58 | 
            +
            executables:
         | 
| 59 | 
            +
            - laterbox
         | 
| 60 | 
            +
            extensions: []
         | 
| 61 | 
            +
            extra_rdoc_files: []
         | 
| 62 | 
            +
            files:
         | 
| 63 | 
            +
            - README.md
         | 
| 64 | 
            +
            - Rakefile
         | 
| 65 | 
            +
            - exe/laterbox
         | 
| 66 | 
            +
            - laterbox.gemspec
         | 
| 67 | 
            +
            - lib/laterbox.rb
         | 
| 68 | 
            +
            - lib/laterbox/bootloader.rb
         | 
| 69 | 
            +
            - lib/laterbox/command.rb
         | 
| 70 | 
            +
            - lib/laterbox/config.rb
         | 
| 71 | 
            +
            - lib/laterbox/version.rb
         | 
| 72 | 
            +
            - sig/laterbox
         | 
| 73 | 
            +
            homepage: https://github.com/ryancyq/laterbox
         | 
| 74 | 
            +
            licenses: []
         | 
| 75 | 
            +
            metadata:
         | 
| 76 | 
            +
              allowed_push_host: https://rubygems.org
         | 
| 77 | 
            +
              homepage_uri: https://github.com/ryancyq/laterbox
         | 
| 78 | 
            +
              source_code_uri: https://github.com/ryancyq/laterbox
         | 
| 79 | 
            +
              changelog_uri: https://github.com/ryancyq/laterbox/blob/main/CHANGELOG.md
         | 
| 80 | 
            +
              github_repo: ssh://github.com/ryancyq/laterbox
         | 
| 81 | 
            +
            post_install_message: 
         | 
| 82 | 
            +
            rdoc_options: []
         | 
| 83 | 
            +
            require_paths:
         | 
| 84 | 
            +
            - lib
         | 
| 85 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 86 | 
            +
              requirements:
         | 
| 87 | 
            +
              - - ">="
         | 
| 88 | 
            +
                - !ruby/object:Gem::Version
         | 
| 89 | 
            +
                  version: 3.0.0
         | 
| 90 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 91 | 
            +
              requirements:
         | 
| 92 | 
            +
              - - ">"
         | 
| 93 | 
            +
                - !ruby/object:Gem::Version
         | 
| 94 | 
            +
                  version: 1.3.1
         | 
| 95 | 
            +
            requirements: []
         | 
| 96 | 
            +
            rubygems_version: 3.4.10
         | 
| 97 | 
            +
            signing_key: 
         | 
| 98 | 
            +
            specification_version: 4
         | 
| 99 | 
            +
            summary: A transactional outbox implementation for event publishing in Ruby.
         | 
| 100 | 
            +
            test_files: []
         |