shitekiq 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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 51f79aa7c33ba699ba1c61004f291a8b4d22ab67db3650db77bbacd055f81764
4
+ data.tar.gz: 1dccf7c7cf823088f0f92fc4fcaac5aa3baea12b05eb6c7df8e9abc07ada72c2
5
+ SHA512:
6
+ metadata.gz: fa17f196957ed6da5ea545f97c8dd7760216d5d5fcf5e9514ec402db719d42429c8ad8ba15163b0818d6880a90315ee5d61faaaf14ab67133f684f6e29e7e0b3
7
+ data.tar.gz: 380e3719d2d85251afc71731ed5df382077131c2638f06753d7fa5f66aa73c46335fc6e0f2023cd66f34aea599258efc54fceae8b4c6e345113fbff5a0297bd7
data/.DS_Store ADDED
Binary file
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2022-03-23
4
+
5
+ - Initial release
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in shitekiq.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "rspec", "~> 3.0"
11
+
12
+ gem "rubocop", "~> 1.21"
data/Gemfile.lock ADDED
@@ -0,0 +1,59 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ shitekiq (0.1.0)
5
+ json
6
+ redis
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ ast (2.4.2)
12
+ diff-lcs (1.5.0)
13
+ json (2.6.1)
14
+ parallel (1.22.0)
15
+ parser (3.1.1.0)
16
+ ast (~> 2.4.1)
17
+ rainbow (3.1.1)
18
+ rake (13.0.6)
19
+ redis (4.6.0)
20
+ regexp_parser (2.2.1)
21
+ rexml (3.2.5)
22
+ rspec (3.11.0)
23
+ rspec-core (~> 3.11.0)
24
+ rspec-expectations (~> 3.11.0)
25
+ rspec-mocks (~> 3.11.0)
26
+ rspec-core (3.11.0)
27
+ rspec-support (~> 3.11.0)
28
+ rspec-expectations (3.11.0)
29
+ diff-lcs (>= 1.2.0, < 2.0)
30
+ rspec-support (~> 3.11.0)
31
+ rspec-mocks (3.11.0)
32
+ diff-lcs (>= 1.2.0, < 2.0)
33
+ rspec-support (~> 3.11.0)
34
+ rspec-support (3.11.0)
35
+ rubocop (1.26.1)
36
+ parallel (~> 1.10)
37
+ parser (>= 3.1.0.0)
38
+ rainbow (>= 2.2.2, < 4.0)
39
+ regexp_parser (>= 1.8, < 3.0)
40
+ rexml
41
+ rubocop-ast (>= 1.16.0, < 2.0)
42
+ ruby-progressbar (~> 1.7)
43
+ unicode-display_width (>= 1.4.0, < 3.0)
44
+ rubocop-ast (1.16.0)
45
+ parser (>= 3.1.1.0)
46
+ ruby-progressbar (1.11.0)
47
+ unicode-display_width (2.1.0)
48
+
49
+ PLATFORMS
50
+ x86_64-darwin-20
51
+
52
+ DEPENDENCIES
53
+ rake (~> 13.0)
54
+ rspec (~> 3.0)
55
+ rubocop (~> 1.21)
56
+ shitekiq!
57
+
58
+ BUNDLED WITH
59
+ 2.3.10
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 Julien Pierlot
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,45 @@
1
+ # Shitekiq
2
+
3
+ Welcome to Shitekiq. Like Sidekiq, but with less features.
4
+
5
+ Backend for background processing jobs.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'shitekiq'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle install
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install shitekiq
22
+
23
+ ## Usage with rails
24
+
25
+ For Rails, create a `shitekiq.rb` initializer file and set your backend and pool size:
26
+ ```ruby
27
+ Shitekiq.configure do |config|
28
+ config.pool_size = 3 # default to 5
29
+ config.backend = Shitekiq::Backend::Redis.new # default to ruby Queue.new
30
+ end
31
+ ```
32
+
33
+ ## Development
34
+
35
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
36
+
37
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
38
+
39
+ ## Contributing
40
+
41
+ Bug reports and pull requests are welcome on GitHub at https://github.com/julienpierlot/shitekiq.
42
+
43
+ ## License
44
+
45
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
@@ -0,0 +1,23 @@
1
+ require 'redis'
2
+ require 'json'
3
+
4
+ module Shitekiq
5
+ module Backend
6
+ class Redis
7
+ def initialize(connection = ::Redis.new)
8
+ @connection = connection
9
+ end
10
+
11
+ def push(job_data)
12
+ @connection.lpush('shitekiq:queue', JSON.dump(job_data))
13
+ end
14
+
15
+ def pop
16
+ _queue, job = @connection.brpop('shitekiq:queue')
17
+ payload = JSON.parse(job, symbolize_names: true)
18
+ payload[:job] = Object.const_get(payload[:job])
19
+ payload
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Shitekiq
4
+ VERSION = "0.1.0"
5
+ end
data/lib/shitekiq.rb ADDED
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "shitekiq/version"
4
+ require_relative "shitekiq/backend/redis"
5
+
6
+ module Shitekiq
7
+ class Error < StandardError; end
8
+
9
+ def self.included(base)
10
+ base.extend(ClassMethods)
11
+ end
12
+
13
+ def self.configure(&block)
14
+ yield self
15
+ end
16
+
17
+ def self.backend
18
+ @backend ||= Queue.new
19
+ end
20
+
21
+ def self.backend=(provider)
22
+ @backend = provider
23
+ end
24
+
25
+ def self.pool_size=(count)
26
+ count.times do |number|
27
+ thread = Thread.new do
28
+ loop do
29
+ payload = backend.pop
30
+ job = payload[:job]
31
+ job.new.perform(payload[:args])
32
+ end
33
+ end
34
+ thread.name = "Thread #{number + 1}"
35
+ end
36
+ end
37
+
38
+ module ClassMethods
39
+ def perform_now(*args)
40
+ new.perform(*args)
41
+ end
42
+
43
+ def perform_async(*args)
44
+ Shitekiq.backend.push(job: self, args: args)
45
+ end
46
+ end
47
+
48
+ def perform(*args)
49
+ raise NotImplementedError
50
+ end
51
+ end
Binary file
data/sig/shitekiq.rbs ADDED
@@ -0,0 +1,4 @@
1
+ module Shitekiq
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,99 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: shitekiq
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Julien Pierlot
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2022-03-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: json
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
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: redis
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Like Sidekiq, but with less features
56
+ email:
57
+ - pierlot.julien@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".DS_Store"
63
+ - CHANGELOG.md
64
+ - Gemfile
65
+ - Gemfile.lock
66
+ - LICENSE.txt
67
+ - README.md
68
+ - Rakefile
69
+ - lib/shitekiq.rb
70
+ - lib/shitekiq/backend/redis.rb
71
+ - lib/shitekiq/version.rb
72
+ - pkg/shitekiq-0.1.0.gem
73
+ - sig/shitekiq.rbs
74
+ homepage: https://github.com/julienpierlot/shitekiq
75
+ licenses:
76
+ - MIT
77
+ metadata:
78
+ homepage_uri: https://github.com/julienpierlot/shitekiq
79
+ source_code_uri: https://github.com/julienpierlot/shitekiq
80
+ post_install_message:
81
+ rdoc_options: []
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: 2.6.0
89
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ requirements: []
95
+ rubygems_version: 3.2.3
96
+ signing_key:
97
+ specification_version: 4
98
+ summary: Ruby backend job processing.
99
+ test_files: []