herdst_worker 0.1.0 → 0.1.5
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 +4 -4
- data/bin/herdst_worker +11 -5
- data/lib/herdst_worker/adapters/database.rb +22 -18
- data/lib/herdst_worker/adapters/sentry.rb +14 -10
- data/lib/herdst_worker/application/facade.rb +3 -2
- data/lib/herdst_worker/configuration/facade.rb +2 -2
- data/lib/herdst_worker/configuration/metadata.rb +3 -3
- data/lib/herdst_worker/version.rb +1 -1
- metadata +2 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 2a22c87720c3490c3c559fb6504879578873ee9528ba097ac87b734cbe9006e9
         | 
| 4 | 
            +
              data.tar.gz: 3573d7bf2938987eb30746c2d3d0c8f81550e48490b4e86d64b712677a19cc43
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 42b58f80f8afd138a3e293b4c03281a04175a0c99c0e03f53bc5290055ca9ac74d795b9375c244ecfc2a14c53aa01cb1843234ff3f4fdf0e441cd3efc9eb652c
         | 
| 7 | 
            +
              data.tar.gz: 739409b7e24a5af700013e0baaede632471a7ff0a876a095c85ab5a5c6f7c9e3cdc9431115b5f02751e349e62915972af6bf9fd08af06e5aae915f73dbb3e08f
         | 
    
        data/bin/herdst_worker
    CHANGED
    
    | @@ -1,15 +1,21 @@ | |
| 1 1 | 
             
            #!/usr/bin/env ruby
         | 
| 2 2 |  | 
| 3 | 
            -
            args =  | 
| 3 | 
            +
            args = ARGV
         | 
| 4 | 
            +
                .flat_map { |s| s.scan(/--?([^=\s]+)(?:=(\S+))?/) }
         | 
| 5 | 
            +
                .select { |i| i[1] != "" }
         | 
| 4 6 |  | 
| 5 | 
            -
             | 
| 7 | 
            +
            arg_pair = Hash[ args ]
         | 
| 8 | 
            +
            application_name = arg_pair["name"]
         | 
| 9 | 
            +
            application_file = arg_pair["application"] || "application.rb"
         | 
| 6 10 | 
             
            application_path = "#{Dir.pwd}/#{application_file}"
         | 
| 7 | 
            -
            application_env =  | 
| 8 | 
            -
            queue_enabled =  | 
| 11 | 
            +
            application_env = arg_pair["env"] || "production"
         | 
| 12 | 
            +
            queue_enabled = arg_pair["queue_enabled"] == "false" ? false : true
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            raise "Please specify a name for the application E.g. --name=[name]" unless application_name
         | 
| 9 15 |  | 
| 10 16 | 
             
            require_relative "../lib/herdst_worker"
         | 
| 11 17 |  | 
| 12 | 
            -
            application_instance = HerdstWorker::Application.new(application_env, queue_enabled)
         | 
| 18 | 
            +
            application_instance = HerdstWorker::Application.new(application_env, application_name, queue_enabled)
         | 
| 13 19 |  | 
| 14 20 | 
             
            require_relative application_path
         | 
| 15 21 |  | 
| @@ -4,25 +4,29 @@ module HerdstWorker | |
| 4 4 |  | 
| 5 5 |  | 
| 6 6 | 
             
                        def self.setup(app)
         | 
| 7 | 
            -
                             | 
| 8 | 
            -
             | 
| 9 | 
            -
             | 
| 10 | 
            -
                                 | 
| 7 | 
            +
                            begin
         | 
| 8 | 
            +
                                db_config = app.config_for(:database)
         | 
| 9 | 
            +
                                
         | 
| 10 | 
            +
                                if app.config.is_dev?
         | 
| 11 | 
            +
                                    ActiveRecord::Base.logger = app.logger.activerecord
         | 
| 12 | 
            +
                                end
         | 
| 13 | 
            +
                                
         | 
| 14 | 
            +
                                ActiveRecord::Base.default_timezone = :utc
         | 
| 15 | 
            +
                                ActiveRecord::Base.establish_connection(
         | 
| 16 | 
            +
                                    adapter:    db_config[:adapter],
         | 
| 17 | 
            +
                                    encoding:   db_config[:encoding],
         | 
| 18 | 
            +
                                    charset:    db_config[:charset],
         | 
| 19 | 
            +
                                    collation:  db_config[:collation],
         | 
| 20 | 
            +
                                    pool:       db_config[:pool],
         | 
| 21 | 
            +
                                    host:       db_config[:host],
         | 
| 22 | 
            +
                                    username:   db_config[:username],
         | 
| 23 | 
            +
                                    password:   db_config[:password],
         | 
| 24 | 
            +
                                    database:   db_config[:database]
         | 
| 25 | 
            +
                                )
         | 
| 26 | 
            +
                                ActiveRecord::Base.connection.enable_query_cache!
         | 
| 27 | 
            +
                            rescue Exception => ex
         | 
| 28 | 
            +
                                app.logger.error ex.message
         | 
| 11 29 | 
             
                            end
         | 
| 12 | 
            -
                            
         | 
| 13 | 
            -
                            ActiveRecord::Base.default_timezone = :utc
         | 
| 14 | 
            -
                            ActiveRecord::Base.establish_connection(
         | 
| 15 | 
            -
                                adapter:    db_config[:adapter],
         | 
| 16 | 
            -
                                encoding:   db_config[:encoding],
         | 
| 17 | 
            -
                                charset:    db_config[:charset],
         | 
| 18 | 
            -
                                collation:  db_config[:collation],
         | 
| 19 | 
            -
                                pool:       db_config[:pool],
         | 
| 20 | 
            -
                                host:       db_config[:host],
         | 
| 21 | 
            -
                                username:   db_config[:username],
         | 
| 22 | 
            -
                                password:   db_config[:password],
         | 
| 23 | 
            -
                                database:   db_config[:database]
         | 
| 24 | 
            -
                            )
         | 
| 25 | 
            -
                            ActiveRecord::Base.connection.enable_query_cache!
         | 
| 26 30 | 
             
                        end
         | 
| 27 31 |  | 
| 28 32 |  | 
| @@ -7,16 +7,20 @@ module HerdstWorker | |
| 7 7 |  | 
| 8 8 |  | 
| 9 9 | 
             
                        def self.setup(app)
         | 
| 10 | 
            -
                             | 
| 11 | 
            -
             | 
| 12 | 
            -
             | 
| 13 | 
            -
             | 
| 14 | 
            -
             | 
| 15 | 
            -
                                 | 
| 16 | 
            -
             | 
| 17 | 
            -
             | 
| 18 | 
            -
             | 
| 19 | 
            -
             | 
| 10 | 
            +
                            begin
         | 
| 11 | 
            +
                                environment = app.config.metadata[:DEPLOYMENT_ENV]
         | 
| 12 | 
            +
                                release = app.config.metadata[:RELEASE_VERSION]
         | 
| 13 | 
            +
                                sentry_key = app.config.metadata[:SENTRY_KEY]
         | 
| 14 | 
            +
                                
         | 
| 15 | 
            +
                                Raven.configure do |config|
         | 
| 16 | 
            +
                                    config.current_environment = environment
         | 
| 17 | 
            +
                                    config.release = release
         | 
| 18 | 
            +
                                    config.dsn = sentry_key if sentry_key
         | 
| 19 | 
            +
                                    config.environments = ["preview", "production"]
         | 
| 20 | 
            +
                                    config.async = lambda { |event| Thread.new { Raven.send_event(event) } }
         | 
| 21 | 
            +
                                end
         | 
| 22 | 
            +
                            rescue Exception => ex
         | 
| 23 | 
            +
                                app.logger.error ex.message
         | 
| 20 24 | 
             
                            end
         | 
| 21 25 | 
             
                        end
         | 
| 22 26 |  | 
| @@ -15,14 +15,15 @@ module HerdstWorker | |
| 15 15 | 
             
                    attr_accessor :poller_enabled, :queues, :poller_url, :queue
         | 
| 16 16 |  | 
| 17 17 |  | 
| 18 | 
            -
                    def initialize(env, poller_enabled)
         | 
| 18 | 
            +
                    def initialize(env, name, poller_enabled)
         | 
| 19 | 
            +
                        self.name = name
         | 
| 19 20 | 
             
                        self.poller_enabled = poller_enabled
         | 
| 20 21 | 
             
                        self.queues = ActiveSupport::HashWithIndifferentAccess.new
         | 
| 21 22 |  | 
| 22 23 | 
             
                        HerdstWorker.set_application(self)
         | 
| 23 24 |  | 
| 24 25 | 
             
                        self.logger = HerdstWorker::Log::Facade.new(get_logger_level(env))
         | 
| 25 | 
            -
                        self.config = HerdstWorker::Configuration::Facade.new(env)
         | 
| 26 | 
            +
                        self.config = HerdstWorker::Configuration::Facade.new(env, name)
         | 
| 26 27 | 
             
                        self.autoload = HerdstWorker::Autoload::Facade.new(self)
         | 
| 27 28 | 
             
                        self.set_inflections
         | 
| 28 29 |  | 
| @@ -13,11 +13,11 @@ module HerdstWorker | |
| 13 13 | 
             
                        attr_accessor :env, :metadata, :paths, :actions
         | 
| 14 14 |  | 
| 15 15 |  | 
| 16 | 
            -
                        def initialize(env)
         | 
| 16 | 
            +
                        def initialize(env, name)
         | 
| 17 17 | 
             
                            self.env = env.downcase
         | 
| 18 18 |  | 
| 19 19 | 
             
                            self.paths = Paths.new
         | 
| 20 | 
            -
                            self.metadata = Metadata.new(env, self)
         | 
| 20 | 
            +
                            self.metadata = Metadata.new(env, name, self)
         | 
| 21 21 | 
             
                            self.actions = self.config_for(:actions)
         | 
| 22 22 | 
             
                        end
         | 
| 23 23 |  | 
| @@ -13,10 +13,10 @@ module HerdstWorker | |
| 13 13 | 
             
                        attr_accessor :config_suffix, :secrets_suffix
         | 
| 14 14 |  | 
| 15 15 |  | 
| 16 | 
            -
                        def initialize(env, config)
         | 
| 16 | 
            +
                        def initialize(env, name, config)
         | 
| 17 17 | 
             
                            self.config = config
         | 
| 18 | 
            -
                            self.config_suffix = "-service-config"
         | 
| 19 | 
            -
                            self.secrets_suffix = "-service-secrets"
         | 
| 18 | 
            +
                            self.config_suffix = "-#{name}-service-config"
         | 
| 19 | 
            +
                            self.secrets_suffix = "-#{name}-service-secrets"
         | 
| 20 20 |  | 
| 21 21 | 
             
                            self.secrets = {}.with_indifferent_access
         | 
| 22 22 | 
             
                            self.secrets["ENV"] = env
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: herdst_worker
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.1. | 
| 4 | 
            +
              version: 0.1.5
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Herd.St
         | 
| 8 8 | 
             
            autorequire:
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2021-07- | 
| 11 | 
            +
            date: 2021-07-05 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: activesupport
         |