Sha256: 2cc0efc5ba3bb6984cc47de04adc7b6e7b31bf94d5c25a5ca286c13ab613cdf5

Contents?: true

Size: 1.72 KB

Versions: 1

Compression:

Stored size: 1.72 KB

Contents

require 'legion/data/version'
require 'legion/data/settings'
require 'sequel'

require 'legion/data/connection'
require 'legion/data/model'
require 'legion/data/migration'

module Legion
  module Data
    class << self
      def setup
        connection_setup
        migrate
        load_models
        setup_cache
      end

      def connection_setup
        return if Legion::Settings[:data][:connected]

        Legion::Data::Connection.setup
      end

      def migrate
        Legion::Data::Migration.migrate
      end

      def load_models
        Legion::Data::Models.load
      end

      def connection
        Legion::Data::Connection.sequel
      end

      def setup_cache
        return if Legion::Settings[:data][:cache][:enabled]

        return unless defined?(::Legion::Cache)

        # Legion::Data::Model::Relationship.plugin :caching, Legion::Cache, ttl: 10
        # Legion::Data::Model::Runner.plugin :caching, Legion::Cache, ttl: 60
        # Legion::Data::Model::Chain.plugin :caching, Legion::Cache, ttl: 60
        # Legion::Data::Model::Function.plugin :caching, Legion::Cache, ttl: 120
        # Legion::Data::Model::Extension.plugin :caching, Legion::Cache, ttl: 120
        # Legion::Data::Model::Node.plugin :caching, Legion::Cache, ttl: 10
        # Legion::Data::Model::TaskLog.plugin :caching, Legion::Cache, ttl: 12
        # Legion::Data::Model::Task.plugin :caching, Legion::Cache, ttl: 10
        # Legion::Data::Model::User.plugin :caching, Legion::Cache, ttl: 120
        # Legion::Data::Model::Group.plugin :caching, Legion::Cache, ttl: 120
        # Legion::Logging.info 'Legion::Data connected to Legion::Cache'
      end

      def shutdown
        Legion::Data::Connection.shutdown
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
legion-data-1.2.0 lib/legion/data.rb