blackstack-db 1.0.8 → 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 +4 -4
- data/lib/blackstack-db/crdb.rb +1 -3
- data/lib/blackstack-db/postgresql.rb +21 -6
- data/lib/blackstack-db.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: 8be71b6715082bf8ecf71d59781d97cd4a1ec7972196923df1b0d1a3fa9f8aa9
|
|
4
|
+
data.tar.gz: 35c89cc7262a0cb60bd3b169046b4f22a68e6ceb53c52bc72a338ad12a0e4505
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e4647461f8288e49b3de911a62e2021de56cd5265100893b877b87a6090eda638fca26c08057e0c45c6259842fd38739ade20fd3c3629d1e63b1247c210618a1
|
|
7
|
+
data.tar.gz: 6234a0f8fca4968d427c4dbee1e95ae615cc9a4519999ef89235c5f298e42571837a16f7b4ede3e6d9f134fd0ed25d5831cc01ab9e98cb481a70633a1797b493
|
data/lib/blackstack-db/crdb.rb
CHANGED
|
@@ -130,9 +130,7 @@ module BlackStack
|
|
|
130
130
|
|
|
131
131
|
l.logs "Testing connection... "
|
|
132
132
|
begin
|
|
133
|
-
@db = BlackStack::
|
|
134
|
-
BlackStack::CRDB::connection_string # use the connection parameters setting in ./config.rb
|
|
135
|
-
)
|
|
133
|
+
@db = BlackStack::CRDB::connect
|
|
136
134
|
l.logf "success".green
|
|
137
135
|
rescue => e
|
|
138
136
|
l.logf "failed".red
|
|
@@ -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,12 +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
|
|
98
|
+
opts = {}
|
|
99
|
+
opts[:max_connections] = @@db_max_connections if @@db_max_connections
|
|
100
|
+
Sequel.connect(s, **opts)
|
|
84
101
|
end
|
|
85
102
|
|
|
86
103
|
# return a postgresql uuid
|
|
@@ -112,9 +129,7 @@ module BlackStack
|
|
|
112
129
|
|
|
113
130
|
l.logs "Testing connection... "
|
|
114
131
|
begin
|
|
115
|
-
@db = BlackStack::
|
|
116
|
-
BlackStack::PostgreSQL::connection_string # use the connection parameters setting in ./config.rb
|
|
117
|
-
)
|
|
132
|
+
@db = BlackStack::PostgreSQL::connect
|
|
118
133
|
l.logf "success".green
|
|
119
134
|
rescue => e
|
|
120
135
|
l.logf "failed".red
|
|
@@ -125,8 +140,8 @@ module BlackStack
|
|
|
125
140
|
# This validation checks the connection to the correct database.
|
|
126
141
|
begin
|
|
127
142
|
l.logs "Verify database name... "
|
|
128
|
-
s = @db["SELECT datname FROM pg_database"].first
|
|
129
|
-
raise 'Wrong database name' if s
|
|
143
|
+
s = @db["SELECT datname FROM pg_database WHERE datname='#{BlackStack::PostgreSQL::db_name}'"].first
|
|
144
|
+
raise 'Wrong database name' if s.nil?
|
|
130
145
|
l.logf "success".green
|
|
131
146
|
rescue => e
|
|
132
147
|
l.logf "failed".red
|
data/lib/blackstack-db.rb
CHANGED
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.
|
|
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:
|
|
11
|
+
date: 2026-01-20 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: colorize
|