Module: GlassOctopus

Defined in:
lib/glass_octopus.rb,
lib/glass_octopus/runner.rb,
lib/glass_octopus/builder.rb,
lib/glass_octopus/context.rb,
lib/glass_octopus/message.rb,
lib/glass_octopus/version.rb,
lib/glass_octopus/consumer.rb,
lib/glass_octopus/middleware.rb,
lib/glass_octopus/application.rb,
lib/glass_octopus/unit_of_work.rb,
lib/glass_octopus/configuration.rb,
lib/glass_octopus/bounded_executor.rb,
lib/glass_octopus/middleware/sentry.rb,
lib/glass_octopus/middleware/mongoid.rb,
lib/glass_octopus/middleware/new_relic.rb,
lib/glass_octopus/middleware/avro_parser.rb,
lib/glass_octopus/middleware/json_parser.rb,
lib/glass_octopus/middleware/active_record.rb,
lib/glass_octopus/middleware/common_logger.rb,
lib/glass_octopus/connection/options_invalid.rb,
lib/glass_octopus/connection/poseidon_adapter.rb,
lib/glass_octopus/connection/ruby_kafka_adapter.rb

Defined Under Namespace

Modules: Middleware Classes: BoundedExecutor, Builder, Configuration, Context, Message, OptionsInvalid, PoseidonAdapter, RubyKafkaAdapter, Runner

Constant Summary collapse

VERSION =
"1.1.0"

Class Method Summary collapse

Class Method Details

.build { ... } ⇒ #call

Build a middleware stack. Basically a shortcut to Builder.new { }.to_app

Examples:


require "glass_octopus"

app = GlassOctopus.build do
  use GlassOctopus::Middleware::CommonLogger

  run Proc.new { |context|
    puts "Hello, #{context.message.value}"
  }
end

GlassOctopus.run(app) do |config|
  # set config here
end

Yields:

  • use the builder DSL to build your middleware stack

Returns:

  • (#call)

    an application that can be fed into the run

See Also:


47
48
49
# File 'lib/glass_octopus.rb', line 47

def self.build(&block)
  Builder.new(&block).to_app
end

.run(app, runner: Runner) {|config| ... } ⇒ Object

Run an application. The application can be anything that responds to #call. It is invoked with with a context that has the message and other goodies.

Parameters:

  • app (#call)

    application to process messages

  • runner (#run)

    a runner that takes care of running and shutting down the application. See Runner for more details.

Yields:

  • (config)

    configure your application in this block, this is called before connecting to Kafka

Yield Parameters:

Raises:

  • (ArgumentError)

    when no block for configuration is passed


19
20
21
22
23
# File 'lib/glass_octopus.rb', line 19

def self.run(app, runner: Runner, &block)
  raise ArgumentError, "A block must be given to set up the #{name}." unless block_given?
  go_app = Application.new(app, &block)
  runner.run(go_app)
end