tj_lavin

A small wrapper around LavinMQ for job management.

Lavin MQ

An example worker setup file in Lucky/Avram application.

Configuration:

TJLavin.configure do |settings|
  settings.amqp_url = ENV["AMQP_URL"]
  settings.cluster_name = ENV["WORKER_CLUSTER_NAME"]?
  settings.topic_name = ENV["AMQP_TOPIC_NAME"].to_s
end

Worker setup:

require "./app"

Habitat.raise_if_missing_settings!

if LuckyEnv.development?
  Avram::Migrator::Runner.new.ensure_migrated!
  Avram::SchemaEnforcer.ensure_correct_column_mappings!
end

# Disable query cache because all jobs run in the
# same fiber which means infinite cache
Avram.settings.query_cache_enabled = false

# Start the server
TJLavin::Runner.start("worker_cluster_#{ARGV[0]}")

Worker file:

class BMXWorker < TJLavin::QueuedJob
  def perform
    puts "Keep on peddalin'"
  end
end
Repository

tj_lavin

Owner
Statistic
  • 1
  • 1
  • 0
  • 0
  • 1
  • 9 months ago
  • February 8, 2024
License

Links
Synced at

Sun, 17 Nov 2024 07:15:00 GMT

Languages