blackstack-db 1.0.9 → 1.0.10

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bbd6c260dad3244665d28642c195ac7c30c4e793618a63a3d9b5e8d20a0d5222
4
- data.tar.gz: 235c9e11c1dfd0095ae7d0c426a4960499d899c13e5f621c4d55b4048e481f9e
3
+ metadata.gz: 8be71b6715082bf8ecf71d59781d97cd4a1ec7972196923df1b0d1a3fa9f8aa9
4
+ data.tar.gz: 35c89cc7262a0cb60bd3b169046b4f22a68e6ceb53c52bc72a338ad12a0e4505
5
5
  SHA512:
6
- metadata.gz: 8d1e697ab4f75d02f900fc5a095840306ba58170eb7965e6ef2634701e25b7c9ddaf6fa9f68bc91f2e5e28b071d5801af6ac9adfbcdbd04f99c4ecef2a7e4fb1
7
- data.tar.gz: 623ec3594481d480dfa2c015f7b3ef1659c7d25c9eca0f820e9075ff997daef76514c14b8e63064b10e386484c3023a0e62148427317eb25f89baa6511642614
6
+ metadata.gz: e4647461f8288e49b3de911a62e2021de56cd5265100893b877b87a6090eda638fca26c08057e0c45c6259842fd38739ade20fd3c3629d1e63b1247c210618a1
7
+ data.tar.gz: 6234a0f8fca4968d427c4dbee1e95ae615cc9a4519999ef89235c5f298e42571837a16f7b4ede3e6d9f134fd0ed25d5831cc01ab9e98cb481a70633a1797b493
@@ -6,6 +6,7 @@ module BlackStack
6
6
  @@db_name = nil
7
7
  @@db_user = nil
8
8
  @@db_password = nil
9
+ @@db_max_connections = nil
9
10
 
10
11
  # return the connection string for a postgresql database
11
12
  def self.connection_string
@@ -28,6 +29,9 @@ module BlackStack
28
29
  def self.db_password
29
30
  @@db_password
30
31
  end
32
+ def self.db_max_connections
33
+ @@db_max_connections
34
+ end
31
35
 
32
36
  def self.set_db_params(h)
33
37
  # validate: the parameter h is requred
@@ -51,6 +55,15 @@ module BlackStack
51
55
  # validate: the db_password key is required
52
56
  raise 'The key :db_password is required' unless h.has_key?(:db_password)
53
57
 
58
+ # validate: optional :max_connections key
59
+ if h.has_key?(:max_connections)
60
+ value = h[:max_connections]
61
+ unless value.is_a?(Integer) || (value.is_a?(String) && value.to_i.to_s == value)
62
+ raise 'The key :max_connections must be an integer'
63
+ end
64
+ raise 'The key :max_connections must be greater than zero' unless value.to_i > 0
65
+ end
66
+
54
67
  # validate: the :db_url key must be a string
55
68
  raise 'The key :db_url must be a string' unless h[:db_url].is_a?(String)
56
69
 
@@ -75,13 +88,16 @@ module BlackStack
75
88
  @@db_name = h[:db_name]
76
89
  @@db_user = h[:db_user]
77
90
  @@db_password = h[:db_password]
91
+ @@db_max_connections = h[:max_connections] ? h[:max_connections].to_i : nil
78
92
  end # set_db_params
79
93
 
80
94
  # create database connection
81
95
  def self.connect
82
96
  BlackStack::set_db_type(BlackStack::TYPE_POSTGRESQL)
83
97
  s = BlackStack::PostgreSQL.connection_string
84
- Sequel.connect(s)
98
+ opts = {}
99
+ opts[:max_connections] = @@db_max_connections if @@db_max_connections
100
+ Sequel.connect(s, **opts)
85
101
  end
86
102
 
87
103
  # return a postgresql uuid
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blackstack-db
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.9
4
+ version: 1.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leandro Daniel Sardi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-03-29 00:00:00.000000000 Z
11
+ date: 2026-01-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize