filesystem_queue 0.1.0 → 0.1.1
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/CHANGELOG.md +4 -1
- data/Gemfile.lock +2 -1
- data/README.md +18 -4
- data/filesystem_queue.gemspec +2 -1
- data/lib/filesystem_queue/version.rb +1 -1
- data/lib/filesystem_queue.rb +15 -11
- 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: 51d0fe57ac440673ae98c9fa2a782ddfe6552450bf984dd44c4edc0d0f972e2f
|
4
|
+
data.tar.gz: e61ded49f3eb2919f0da55ce20627a5d3a732c22c71bf747b64def5f42f0e2a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ecb0a4780632dcedcbe33593460c9b827c4bc1402b967fe9cd010ca3cbb2ab97f4e7bcdcbe33f707caf7bf8a90d964c65f8e773cf806f2a2e3436e203398c85
|
7
|
+
data.tar.gz: 73b113cb15f2cd5eb285565ceb82c62b8d3b0f6180c49c75c374228becd4ba0f1877dc49794cc01b7ca0e3b4442b43614d229e21f093e43739e4c7ab84da2eed
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,18 +1,32 @@
|
|
1
1
|
# FilesystemQueue
|
2
2
|
|
3
|
+
[](https://badge.fury.io/rb/filesystem_queue)
|
4
|
+
|
3
5
|
`FileSystemQueue` is a persistent queue system based on the local filesystem. It allows you to enqueue and dequeue jobs, and keeps track of completed and failed jobs.
|
4
6
|
|
5
|
-
## Installation
|
6
7
|
|
7
|
-
|
8
|
+
## What is this for?
|
9
|
+
|
10
|
+
`FileSystemQueue` is designed for applications that need a simple, embedded queue system with minimal footprint. It consists of just a single class and utilizes your local filesystem for storage. This makes it an excellent choice for lightweight applications or development environments where setting up a full-fledged queue service is overkill. If you are looking to scale up your queue into a service architecture, Ruby offers other solutions like Resque (Redis-based), or various suites from cloud providers such as AWS-SQS.
|
11
|
+
|
12
|
+
### Features
|
13
|
+
|
14
|
+
- **Persistence**: Jobs are stored on the filesystem, ensuring they are not lost between application restarts.
|
15
|
+
- **Minimal Overhead**: No need for external dependencies or services.
|
16
|
+
- **Ease of Use**: Simple API for enqueuing and dequeuing jobs.
|
17
|
+
- **Improved Performance**: Enhances filesystem performance by using an index file that keeps track of files by the time they are written in the queue.
|
18
|
+
- **Tailored for Local Use**: This system is designed for local use with a single consumer (at the moment).
|
19
|
+
- **Job Management**: Completed and failed jobs are tracked in separate folders for easy management.
|
20
|
+
|
21
|
+
## Installation
|
8
22
|
|
9
23
|
Install the gem and add to the application's Gemfile by executing:
|
10
24
|
|
11
|
-
$ bundle add
|
25
|
+
$ bundle add filesystem_queue
|
12
26
|
|
13
27
|
If bundler is not being used to manage dependencies, install the gem by executing:
|
14
28
|
|
15
|
-
$ gem install
|
29
|
+
$ gem install filesystem_queue
|
16
30
|
|
17
31
|
## Methods
|
18
32
|
|
data/filesystem_queue.gemspec
CHANGED
@@ -9,7 +9,8 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.email = ["carloswestman@gmail.com"]
|
10
10
|
|
11
11
|
spec.summary = "A persistent queue system based on the local filesystem"
|
12
|
-
spec.description = "FilesystemQueue is a Ruby gem that provides a persistent queue system
|
12
|
+
spec.description = "FilesystemQueue is a Ruby gem that provides a persistent queue system "\
|
13
|
+
"using the local filesystem.It allows you to enqueue and dequeue jobs, and keeps track of completed and failed jobs."
|
13
14
|
spec.homepage = "https://github.com/carloswestman/filesystem_queue"
|
14
15
|
spec.license = "MIT"
|
15
16
|
spec.required_ruby_version = ">= 2.6.0"
|
data/lib/filesystem_queue.rb
CHANGED
@@ -31,17 +31,7 @@ module FilesystemQueue
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def dequeue
|
34
|
-
job_file =
|
35
|
-
File.open(@index_file, "r+") do |f|
|
36
|
-
lines = f.each_line.to_a
|
37
|
-
return nil if lines.empty?
|
38
|
-
|
39
|
-
job_file = lines.shift.strip
|
40
|
-
f.rewind
|
41
|
-
f.write(lines.join)
|
42
|
-
f.truncate(f.pos)
|
43
|
-
end
|
44
|
-
|
34
|
+
job_file = extract_job_file_from_index
|
45
35
|
return nil unless job_file && File.exist?(job_file)
|
46
36
|
|
47
37
|
job_data = JSON.parse(File.read(job_file), symbolize_names: true)
|
@@ -71,5 +61,19 @@ module FilesystemQueue
|
|
71
61
|
rescue StandardError => e
|
72
62
|
puts "Failed to move job file: #{e.message}"
|
73
63
|
end
|
64
|
+
|
65
|
+
def extract_job_file_from_index
|
66
|
+
job_file = nil
|
67
|
+
File.open(@index_file, "r+") do |f|
|
68
|
+
lines = f.each_line.to_a
|
69
|
+
return nil if lines.empty?
|
70
|
+
|
71
|
+
job_file = lines.shift.strip
|
72
|
+
f.rewind
|
73
|
+
f.write(lines.join)
|
74
|
+
f.truncate(f.pos)
|
75
|
+
end
|
76
|
+
job_file
|
77
|
+
end
|
74
78
|
end
|
75
79
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: filesystem_queue
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carlos Westman
|
@@ -11,7 +11,7 @@ cert_chain: []
|
|
11
11
|
date: 2024-09-13 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: FilesystemQueue is a Ruby gem that provides a persistent queue system
|
14
|
-
using the local filesystem.
|
14
|
+
using the local filesystem.It allows you to enqueue and dequeue jobs, and keeps
|
15
15
|
track of completed and failed jobs.
|
16
16
|
email:
|
17
17
|
- carloswestman@gmail.com
|