pg-locks-monitor 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 38fe7be18449c8a637a4f6a756228055f217f4e2fa1c47eb84609009c31793cf
4
+ data.tar.gz: 19e9b7bcacde528b1b0c34d4c2c28f2f482e6573742fe10536af51cbeb68db75
5
+ SHA512:
6
+ metadata.gz: 9b947dcacbdaccc1d2ce67244c7c054882b9120a996ea3a8c7b3b99ae9e516065920201fa42d5c0f536fcef3296c86a6a4066c3319d464a3d726f19ca2e6e481
7
+ data.tar.gz: ad98c65cf24043c9381579442731e74d26784df9886a6633913fc9c9fb1ba20e76470a53b12b11b24b588fa3d8014364194eca34f0b7c96caaa8e632e1edd66f
@@ -0,0 +1,127 @@
1
+ name: Ruby CI
2
+
3
+ on:
4
+ push:
5
+ branches: [ main ]
6
+ pull_request:
7
+ branches: [ main ]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ fail-fast: false
14
+ matrix:
15
+ ruby-version: ['3.2', '3.1', '3.0', '2.7', '2.6']
16
+ steps:
17
+ - uses: actions/checkout@v3
18
+ - name: Run PostgreSQL 11
19
+ run: |
20
+ docker run --env POSTGRES_USER=postgres \
21
+ --env POSTGRES_DB=pg-locks-monitor-test \
22
+ --env POSTGRES_PASSWORD=secret \
23
+ -d -p 5432:5432 postgres:11.18-alpine \
24
+ postgres -c shared_preload_libraries=pg_stat_statements
25
+ - name: Run PostgreSQL 12
26
+ run: |
27
+ docker run --env POSTGRES_USER=postgres \
28
+ --env POSTGRES_DB=pg-locks-monitor-test \
29
+ --env POSTGRES_PASSWORD=secret \
30
+ -d -p 5433:5432 postgres:12.13-alpine \
31
+ postgres -c shared_preload_libraries=pg_stat_statements
32
+ - name: Run PostgreSQL 13
33
+ run: |
34
+ docker run --env POSTGRES_USER=postgres \
35
+ --env POSTGRES_DB=pg-locks-monitor-test \
36
+ --env POSTGRES_PASSWORD=secret \
37
+ -d -p 5434:5432 postgres:13.9-alpine \
38
+ postgres -c shared_preload_libraries=pg_stat_statements
39
+ - name: Run PostgreSQL 14
40
+ run: |
41
+ docker run --env POSTGRES_USER=postgres \
42
+ --env POSTGRES_DB=pg-locks-monitor-test \
43
+ --env POSTGRES_PASSWORD=secret \
44
+ -d -p 5435:5432 postgres:14.6-alpine \
45
+ postgres -c shared_preload_libraries=pg_stat_statements
46
+ - name: Run PostgreSQL 15
47
+ run: |
48
+ docker run --env POSTGRES_USER=postgres \
49
+ --env POSTGRES_DB=pg-locks-monitor-test \
50
+ --env POSTGRES_PASSWORD=secret \
51
+ -d -p 5436:5432 postgres:15.1-alpine \
52
+ postgres -c shared_preload_libraries=pg_stat_statements
53
+ sleep 15
54
+ - name: Set up Ruby ${{ matrix.ruby-version }}
55
+ uses: ruby/setup-ruby@v1
56
+ with:
57
+ ruby-version: ${{ matrix.ruby-version }}
58
+ - name: Setup dependencies
59
+ run: |
60
+ gem install bundler -v 2.4.22
61
+ sudo apt-get update --allow-releaseinfo-change
62
+ sudo apt install postgresql-client
63
+ sudo apt install libpq-dev
64
+ bundle config set --local path 'vendor/bundle'
65
+ bundle install
66
+ sleep 10
67
+ - name: Run tests for PG 11
68
+ env:
69
+ PG_VERSION: 11
70
+ POSTGRES_HOST: localhost
71
+ POSTGRES_USER: postgres
72
+ POSTGRES_DB: pg-locks-monitor-test
73
+ POSTGRES_PASSWORD: secret
74
+ DATABASE_URL: postgresql://postgres:secret@localhost:5432/pg-locks-monitor-test
75
+ run: |
76
+ bundle exec rspec spec/
77
+ - name: Run tests for PG 11
78
+ env:
79
+ PG_VERSION: 11
80
+ POSTGRES_HOST: localhost
81
+ POSTGRES_USER: postgres
82
+ POSTGRES_DB: pg-locks-monitor-test
83
+ POSTGRES_PASSWORD: secret
84
+ DATABASE_URL: postgresql://postgres:secret@localhost:5432/pg-locks-monitor-test
85
+ run: |
86
+ bundle exec rspec spec/
87
+ - name: Run tests for PG 12
88
+ env:
89
+ PG_VERSION: 12
90
+ POSTGRES_HOST: localhost
91
+ POSTGRES_USER: postgres
92
+ POSTGRES_DB: pg-locks-monitor-test
93
+ POSTGRES_PASSWORD: secret
94
+ DATABASE_URL: postgresql://postgres:secret@localhost:5433/pg-locks-monitor-test
95
+ run: |
96
+ bundle exec rspec spec/
97
+ - name: Run tests for PG 13
98
+ env:
99
+ PG_VERSION: 13
100
+ POSTGRES_HOST: localhost
101
+ POSTGRES_USER: postgres
102
+ POSTGRES_DB: pg-locks-monitor-test
103
+ POSTGRES_PASSWORD: secret
104
+ DATABASE_URL: postgresql://postgres:secret@localhost:5434/pg-locks-monitor-test
105
+ run: |
106
+ bundle exec rspec spec/
107
+ - name: Run tests for PG 14
108
+ env:
109
+ PG_VERSION: 14
110
+ POSTGRES_HOST: localhost
111
+ POSTGRES_USER: postgres
112
+ POSTGRES_DB: pg-locks-monitor-test
113
+ POSTGRES_PASSWORD: secret
114
+ DATABASE_URL: postgresql://postgres:secret@localhost:5435/pg-locks-monitor-test
115
+ run: |
116
+ bundle exec rspec spec/
117
+ - name: Run tests for PG 15
118
+ env:
119
+ PG_VERSION: 15
120
+ POSTGRES_HOST: localhost
121
+ POSTGRES_USER: postgres
122
+ POSTGRES_DB: pg-locks-monitor-test
123
+ POSTGRES_PASSWORD: secret
124
+ DATABASE_URL: postgresql://postgres:secret@localhost:5436/pg-locks-monitor-test
125
+ run: |
126
+ bundle exec rspec spec/
127
+
data/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ Gemfile.lock
2
+ .ruby-version
3
+ pkg/
4
+ *.gem
5
+ docker-compose.yml
6
+
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright © Paweł Urbanek 2024
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # PG Locks Monitor [![Gem Version](https://badge.fury.io/rb/pg-locks-monitor.svg)](https://badge.fury.io/rb/pg-locks-monitor) [![GH Actions](https://github.com/pawurb/pg-locks-monitor/actions/workflows/ci.yml/badge.svg)](https://github.com/pawurb/pg-locks-monitor/actions)
2
+
3
+ WIP
data/Rakefile ADDED
@@ -0,0 +1,9 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ desc "Test all PG versions"
7
+ task :test_all do
8
+ system("PG_VERSION=11 bundle exec rspec spec/ && PG_VERSION=12 bundle exec rspec spec/ && PG_VERSION=13 bundle exec rspec spec/ && PG_VERSION=14 bundle exec rspec spec/")
9
+ end
@@ -0,0 +1,39 @@
1
+ version: '3'
2
+
3
+ services:
4
+ postgres11:
5
+ image: postgres:11.16-alpine
6
+ command: postgres -c shared_preload_libraries=pg_stat_statements
7
+ environment:
8
+ POSTGRES_USER: postgres
9
+ POSTGRES_DB: pg-locks-monitor-test
10
+ POSTGRES_PASSWORD: secret
11
+ ports:
12
+ - '5432:5432'
13
+ postgres12:
14
+ image: postgres:12.11-alpine
15
+ command: postgres -c shared_preload_libraries=pg_stat_statements
16
+ environment:
17
+ POSTGRES_USER: postgres
18
+ POSTGRES_DB: pg-locks-monitor-test
19
+ POSTGRES_PASSWORD: secret
20
+ ports:
21
+ - '5433:5432'
22
+ postgres13:
23
+ image: postgres:13.7-alpine
24
+ command: postgres -c shared_preload_libraries=pg_stat_statements
25
+ environment:
26
+ POSTGRES_USER: postgres
27
+ POSTGRES_DB: pg-locks-monitor-test
28
+ POSTGRES_PASSWORD: secret
29
+ ports:
30
+ - '5434:5432'
31
+ postgres14:
32
+ image: postgres:14.3-alpine
33
+ command: postgres -c shared_preload_libraries=pg_stat_statements
34
+ environment:
35
+ POSTGRES_USER: postgres
36
+ POSTGRES_DB: pg-locks-monitor-test
37
+ POSTGRES_PASSWORD: secret
38
+ ports:
39
+ - '5435:5432'
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "uri"
4
+ require "pg"
5
+
6
+ module PgLocksMonitor
7
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PgLocksMonitor
4
+ VERSION = "0.0.1"
5
+ end
@@ -0,0 +1,26 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "pg_locks_monitor/version"
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "pg-locks-monitor"
8
+ s.version = PgLocksMonitor::VERSION
9
+ s.authors = ["pawurb"]
10
+ s.email = ["contact@pawelurbanek.com"]
11
+ s.summary = %q{ Observe PostgreSQL database locks obtained by your Ruby application. }
12
+ s.description = %q{ This gem allows to monitor and notify about PostgreSQL database locks which meet certain criteria. You can report locks which are held for a certain amount of time, or locks which are held by a certain query. }
13
+ s.homepage = "http://github.com/pawurb/pg-locks-monitor"
14
+ s.files = `git ls-files`.split("\n")
15
+ s.test_files = s.files.grep(%r{^(spec)/})
16
+ s.require_paths = ["lib"]
17
+ s.license = "MIT"
18
+ s.add_dependency "ruby-pg-extras"
19
+ s.add_development_dependency "rake"
20
+ s.add_development_dependency "rspec"
21
+ s.add_development_dependency "rufo"
22
+
23
+ if s.respond_to?(:metadata=)
24
+ s.metadata = { "rubygems_mfa_required" => "true" }
25
+ end
26
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
4
+
5
+ describe PgLocksMonitor do
6
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rubygems"
4
+ require "bundler/setup"
5
+ require_relative "../lib/pg-locks-monitor"
6
+
7
+ pg_version = ENV["PG_VERSION"]
8
+
9
+ port = if pg_version == "11"
10
+ "5432"
11
+ elsif pg_version == "12"
12
+ "5433"
13
+ elsif pg_version == "13"
14
+ "5434"
15
+ elsif pg_version == "14"
16
+ "5435"
17
+ else
18
+ "5432"
19
+ end
20
+
21
+ ENV["DATABASE_URL"] ||= "postgresql://postgres:secret@localhost:#{port}/pg-locks-monitor-test"
metadata ADDED
@@ -0,0 +1,116 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pg-locks-monitor
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - pawurb
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2024-08-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: ruby-pg-extras
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rufo
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: " This gem allows to monitor and notify about PostgreSQL database locks
70
+ which meet certain criteria. You can report locks which are held for a certain amount
71
+ of time, or locks which are held by a certain query. "
72
+ email:
73
+ - contact@pawelurbanek.com
74
+ executables: []
75
+ extensions: []
76
+ extra_rdoc_files: []
77
+ files:
78
+ - ".github/workflows/ci.yml"
79
+ - ".gitignore"
80
+ - Gemfile
81
+ - LICENSE.txt
82
+ - README.md
83
+ - Rakefile
84
+ - docker-compose.yml.sample
85
+ - lib/pg-locks-monitor.rb
86
+ - lib/pg_locks_monitor/version.rb
87
+ - pg-locks-monitor.gemspec
88
+ - spec/smoke_spec.rb
89
+ - spec/spec_helper.rb
90
+ homepage: http://github.com/pawurb/pg-locks-monitor
91
+ licenses:
92
+ - MIT
93
+ metadata:
94
+ rubygems_mfa_required: 'true'
95
+ post_install_message:
96
+ rdoc_options: []
97
+ require_paths:
98
+ - lib
99
+ required_ruby_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ required_rubygems_version: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ requirements: []
110
+ rubygems_version: 3.5.4
111
+ signing_key:
112
+ specification_version: 4
113
+ summary: Observe PostgreSQL database locks obtained by your Ruby application.
114
+ test_files:
115
+ - spec/smoke_spec.rb
116
+ - spec/spec_helper.rb