lean_pool 0.1.0
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 +7 -0
- data/.rspec +3 -0
- data/.rspec_status +195 -0
- data/.rubocop.yml +14 -0
- data/CHANGELOG.md +19 -0
- data/Gemfile +10 -0
- data/LICENSE.txt +21 -0
- data/PUBLISH.md +66 -0
- data/QUICKSTART.md +88 -0
- data/README.md +324 -0
- data/Rakefile +11 -0
- data/examples/basic_usage.rb +73 -0
- data/lean_pool.gemspec +38 -0
- data/lib/lean_pool/errors.rb +69 -0
- data/lib/lean_pool/http_pool.rb +206 -0
- data/lib/lean_pool/pool.rb +441 -0
- data/lib/lean_pool/version.rb +14 -0
- data/lib/lean_pool.rb +62 -0
- metadata +78 -0
data/lib/lean_pool.rb
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "concurrent-ruby"
|
|
4
|
+
require_relative "lean_pool/version"
|
|
5
|
+
require_relative "lean_pool/pool"
|
|
6
|
+
require_relative "lean_pool/errors"
|
|
7
|
+
require_relative "lean_pool/http_pool"
|
|
8
|
+
|
|
9
|
+
# LeanPool is a lightweight, process-free resource pool implementation for Ruby.
|
|
10
|
+
#
|
|
11
|
+
# This module provides efficient resource management without creating per-resource
|
|
12
|
+
# processes, making it perfect for managing sockets, HTTP connections, ports, and
|
|
13
|
+
# other resources that need efficient pooling with minimal overhead.
|
|
14
|
+
#
|
|
15
|
+
# The library is built on top of `concurrent-ruby` for reliable thread safety and
|
|
16
|
+
# provides a clean, Ruby-idiomatic interface for resource pooling.
|
|
17
|
+
#
|
|
18
|
+
# @example Basic usage with a Redis connection pool
|
|
19
|
+
# require 'lean_pool'
|
|
20
|
+
#
|
|
21
|
+
# pool = LeanPool::Pool.new(size: 5) do
|
|
22
|
+
# Redis.new(host: "localhost", port: 6379)
|
|
23
|
+
# end
|
|
24
|
+
#
|
|
25
|
+
# pool.checkout do |redis|
|
|
26
|
+
# redis.get("my_key")
|
|
27
|
+
# redis.set("my_key", "value")
|
|
28
|
+
# end
|
|
29
|
+
#
|
|
30
|
+
# @example Using HTTP connection pool
|
|
31
|
+
# require 'lean_pool'
|
|
32
|
+
#
|
|
33
|
+
# http_pool = LeanPool::HTTPPool.new("api.example.com", 443, size: 10, use_ssl: true)
|
|
34
|
+
# response = http_pool.get("/users")
|
|
35
|
+
# puts response[:body]
|
|
36
|
+
#
|
|
37
|
+
# @example Custom resource pool with state
|
|
38
|
+
# require 'lean_pool'
|
|
39
|
+
#
|
|
40
|
+
# pool = LeanPool::Pool.new(
|
|
41
|
+
# size: 10,
|
|
42
|
+
# timeout: 5.0,
|
|
43
|
+
# lazy: true,
|
|
44
|
+
# pool_state: { database: "production", timeout: 30 }
|
|
45
|
+
# ) do |state|
|
|
46
|
+
# DatabaseConnection.new(
|
|
47
|
+
# database: state[:database],
|
|
48
|
+
# timeout: state[:timeout]
|
|
49
|
+
# )
|
|
50
|
+
# end
|
|
51
|
+
#
|
|
52
|
+
# pool.checkout do |db|
|
|
53
|
+
# db.query("SELECT * FROM users")
|
|
54
|
+
# end
|
|
55
|
+
#
|
|
56
|
+
# @see LeanPool::Pool The main pool class for managing resources
|
|
57
|
+
# @see LeanPool::HTTPPool Example HTTP connection pool implementation
|
|
58
|
+
# @see LeanPool::Error Base error class for all LeanPool errors
|
|
59
|
+
#
|
|
60
|
+
# @since 0.1.0
|
|
61
|
+
module LeanPool
|
|
62
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: lean_pool
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Junaid Farooq
|
|
8
|
+
bindir: exe
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: concurrent-ruby
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - "~>"
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: '1.3'
|
|
19
|
+
type: :runtime
|
|
20
|
+
prerelease: false
|
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
+
requirements:
|
|
23
|
+
- - "~>"
|
|
24
|
+
- !ruby/object:Gem::Version
|
|
25
|
+
version: '1.3'
|
|
26
|
+
description: |
|
|
27
|
+
LeanPool is a tiny, efficient resource pool implementation for Ruby that provides
|
|
28
|
+
direct resource access without per-resource processes. Inspired by Elixir's nimble_pool,
|
|
29
|
+
it's perfect for managing sockets, HTTP connections, ports, and other resources that
|
|
30
|
+
need efficient pooling with minimal overhead.
|
|
31
|
+
email:
|
|
32
|
+
- fjunaid252@gmail.com
|
|
33
|
+
executables: []
|
|
34
|
+
extensions: []
|
|
35
|
+
extra_rdoc_files: []
|
|
36
|
+
files:
|
|
37
|
+
- ".rspec"
|
|
38
|
+
- ".rspec_status"
|
|
39
|
+
- ".rubocop.yml"
|
|
40
|
+
- CHANGELOG.md
|
|
41
|
+
- Gemfile
|
|
42
|
+
- LICENSE.txt
|
|
43
|
+
- PUBLISH.md
|
|
44
|
+
- QUICKSTART.md
|
|
45
|
+
- README.md
|
|
46
|
+
- Rakefile
|
|
47
|
+
- examples/basic_usage.rb
|
|
48
|
+
- lean_pool.gemspec
|
|
49
|
+
- lib/lean_pool.rb
|
|
50
|
+
- lib/lean_pool/errors.rb
|
|
51
|
+
- lib/lean_pool/http_pool.rb
|
|
52
|
+
- lib/lean_pool/pool.rb
|
|
53
|
+
- lib/lean_pool/version.rb
|
|
54
|
+
homepage: https://github.com/half-blood-labs/lean_pool
|
|
55
|
+
licenses:
|
|
56
|
+
- MIT
|
|
57
|
+
metadata:
|
|
58
|
+
homepage_uri: https://github.com/half-blood-labs/lean_pool
|
|
59
|
+
source_code_uri: https://github.com/half-blood-labs/lean_pool
|
|
60
|
+
changelog_uri: https://github.com/half-blood-labs/lean_pool/blob/main/CHANGELOG.md
|
|
61
|
+
rdoc_options: []
|
|
62
|
+
require_paths:
|
|
63
|
+
- lib
|
|
64
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - ">="
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: 3.0.0
|
|
69
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
70
|
+
requirements:
|
|
71
|
+
- - ">="
|
|
72
|
+
- !ruby/object:Gem::Version
|
|
73
|
+
version: '0'
|
|
74
|
+
requirements: []
|
|
75
|
+
rubygems_version: 4.0.3
|
|
76
|
+
specification_version: 4
|
|
77
|
+
summary: A lightweight, process-free resource pool for Ruby using concurrent-ruby
|
|
78
|
+
test_files: []
|