lib/gladys/database.rb
# frozen_string_literal: true module Gladys class Database RESERVED_CONNECTIONS = 4 # Open at least 8 connections to the database for performance reasons. # We don't want to bottleneck gladys and should put as much work on the # database as possible. def self.connect(url, threads: 1, preconnect: true) connections = [(threads || 1) + RESERVED_CONNECTIONS, 8].max database = Sequel.connect(url, max_connections: connections, preconnect: preconnect) database.extension(:pagination) database.extension(:pgvector) database end end end