Sha256: dfe0fe41b394e22af3bb99958da3dde24685f577e40a2a8e47f9344e040bac1f

Contents?: true

Size: 622 Bytes

Versions: 19

Compression:

Stored size: 622 Bytes

Contents

module Endpoints
  class Health < Base
    namespace "/health" do
      get do
        encode({})
      end

      get "/db" do
        database?
        database_available?
        encode({})
      end

      private

      def database?
        raise Pliny::Errors::NotFound if DB.nil?
      end

      def database_available?
        raise Pliny::Errors::ServiceUnavailable unless DB.test_connection
      rescue Sequel::Error => e
        message = e.message.strip
        Pliny.log(db: true, health: true, at: "exception", message: message)
        raise Pliny::Errors::ServiceUnavailable
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
pliny-1.2.0 lib/template/lib/endpoints/health.rb
pliny-1.1.0 lib/template/lib/endpoints/health.rb
pliny-1.0.0 lib/template/lib/endpoints/health.rb
pliny-0.32.0 lib/template/lib/endpoints/health.rb
pliny-0.31.0 lib/template/lib/endpoints/health.rb
pliny-0.30.1 lib/template/lib/endpoints/health.rb
pliny-0.30.0 lib/template/lib/endpoints/health.rb
pliny-0.29.0 lib/template/lib/endpoints/health.rb
pliny-0.28.0 lib/template/lib/endpoints/health.rb
pliny-0.27.1 lib/template/lib/endpoints/health.rb
pliny-0.27.0 lib/template/lib/endpoints/health.rb
pliny-0.26.2 lib/template/lib/endpoints/health.rb
pliny-0.26.1 lib/template/lib/endpoints/health.rb
pliny-0.26.0 lib/template/lib/endpoints/health.rb
pliny-0.25.1 lib/template/lib/endpoints/health.rb
pliny-0.25.0 lib/template/lib/endpoints/health.rb
pliny-0.24.0 lib/template/lib/endpoints/health.rb
pliny-0.23.0 lib/template/lib/endpoints/health.rb
pliny-0.22.0 lib/template/lib/endpoints/health.rb