debounced 3.0.0 → 4.0.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 +4 -4
- data/CHANGELOG.md +19 -1
- data/README.md +34 -6
- data/exe/debounced-server +19 -0
- data/lib/debounced/version.rb +1 -1
- data/lib/debounced.rb +1 -2
- metadata +5 -25
- data/lib/debounced/railtie.rb +0 -9
- data/lib/tasks/debounced.rake +0 -9
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: daa35f9312614c9334ddcb04cd3b569fe070e952b544ceee739b2400a49eefca
|
|
4
|
+
data.tar.gz: 50c4d30cc47754c0370f984fad5f74626199ab43394160d1c538f1b651db0dfe
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1373f6bf67a372eab97c5f932452cb5f244fd015aece067800c1146f1121686c681e3ab7318c050e75cd4a5b28df911dade2965fd3a1a57c9cb9b4a3a5da66f0
|
|
7
|
+
data.tar.gz: ade42af6dc1f0ec81473cdd19ed33e6a3eba213273ebf7dc7478b2018f1b9db31b4e124e7ab81af00cd2374009d4151ef0a5897e4da041bee6982fa739cf3e1c
|
data/CHANGELOG.md
CHANGED
|
@@ -5,7 +5,25 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
-
## [
|
|
8
|
+
## [4.0.0] - 2026-12-02
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- `debounced-server` executable, which starts the server without booting the host application; `--config FILE` loads
|
|
13
|
+
a Ruby file that calls `Debounced.configure`.
|
|
14
|
+
- The previous `debounced:server` rake task booted the whole host application (every gem in its bundle, plus its app
|
|
15
|
+
code) only to read the socket path, so the server used as much memory as the app. The executable loads only the gem
|
|
16
|
+
and the config file, so the server uses about as much memory as the gem alone.
|
|
17
|
+
|
|
18
|
+
### Changed
|
|
19
|
+
|
|
20
|
+
- The default logger writes to stdout instead of `debounced_proxy.log`
|
|
21
|
+
|
|
22
|
+
### Removed
|
|
23
|
+
|
|
24
|
+
- The `debounced:server` rake task and the Railtie that loaded it; start the server with `debounced-server` instead
|
|
25
|
+
|
|
26
|
+
## [3.0.0] - 2026-11-12
|
|
9
27
|
|
|
10
28
|
### Changed
|
|
11
29
|
|
data/README.md
CHANGED
|
@@ -25,28 +25,40 @@ $ gem install debounced
|
|
|
25
25
|
|
|
26
26
|
## Usage
|
|
27
27
|
|
|
28
|
+
Debounced runs as two processes that talk over a Unix socket:
|
|
29
|
+
|
|
30
|
+
- **The server** keeps one timer per activity. It is a standalone executable that loads only the gem and a
|
|
31
|
+
config file.
|
|
32
|
+
- **Your application** sends activity to the server through `Debounced::ServiceProxy`, and runs the callbacks the
|
|
33
|
+
server sends back when timers expire.
|
|
34
|
+
|
|
35
|
+
Both load the same config file, so they agree on the socket.
|
|
36
|
+
|
|
28
37
|
### Configuration
|
|
29
38
|
|
|
30
39
|
```ruby
|
|
31
|
-
# config/
|
|
40
|
+
# config/debounced.rb
|
|
32
41
|
Debounced.configure do |config|
|
|
33
42
|
config.socket_descriptor = '/tmp/my_app.debounceEvents'
|
|
34
43
|
config.wait_timeout = 3 # idle timeout in seconds for a given activity descriptor
|
|
35
44
|
end
|
|
36
45
|
```
|
|
37
46
|
|
|
38
|
-
|
|
47
|
+
By default the gem logs to stdout through `semantic_logger`. Set `config.logger` to use another logger.
|
|
39
48
|
|
|
40
|
-
|
|
49
|
+
### Starting the server
|
|
41
50
|
|
|
42
51
|
```bash
|
|
43
|
-
$ bundle exec
|
|
52
|
+
$ bundle exec debounced-server --config config/debounced.rb
|
|
44
53
|
```
|
|
45
54
|
|
|
46
|
-
|
|
55
|
+
### Debouncing activity in your application
|
|
56
|
+
|
|
57
|
+
Load the same config file, then create a proxy:
|
|
47
58
|
|
|
48
59
|
```ruby
|
|
49
60
|
require 'debounced'
|
|
61
|
+
require_relative 'config/debounced'
|
|
50
62
|
|
|
51
63
|
# Start a background thread to receive notification that events are ready to be handled after debounce wait is complete
|
|
52
64
|
proxy = Debounced::ServiceProxy.new
|
|
@@ -89,6 +101,22 @@ proxy.debounce_activity("my-event-123", 5, event.debounce_callback)
|
|
|
89
101
|
# > Publishing event: #<MyEvent:0x00007f9b1b8b3b40 @test_id="Hello World">
|
|
90
102
|
```
|
|
91
103
|
|
|
104
|
+
### In a Rails application
|
|
105
|
+
|
|
106
|
+
Load the config file from an initializer. The initializer is also the place for settings that only apply to your
|
|
107
|
+
application: Rails' logger, and an `error_handler` for callbacks that raise (callbacks run in your application, never in
|
|
108
|
+
the server).
|
|
109
|
+
|
|
110
|
+
```ruby
|
|
111
|
+
# config/initializers/debounced.rb
|
|
112
|
+
require Rails.root.join('config/debounced')
|
|
113
|
+
|
|
114
|
+
Debounced.configure do |config|
|
|
115
|
+
config.logger = Rails.logger
|
|
116
|
+
config.error_handler = ->(error, callback) { Rails.error.report(error, context: { callback: callback.as_json }) }
|
|
117
|
+
end
|
|
118
|
+
```
|
|
119
|
+
|
|
92
120
|
### Shutting down
|
|
93
121
|
|
|
94
122
|
On SIGTERM the server stops debouncing: pending timers still fire on schedule, requests that arrive afterwards are
|
|
@@ -134,4 +162,4 @@ To measure another server, pass its command: `bin/benchmark node path/to/server.
|
|
|
134
162
|
|
|
135
163
|
## License
|
|
136
164
|
|
|
137
|
-
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
|
165
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require 'optparse'
|
|
5
|
+
require 'debounced'
|
|
6
|
+
require 'debounced/server'
|
|
7
|
+
|
|
8
|
+
# Write each log line as it happens; Ruby buffers stdout when it isn't a terminal (e.g. on Heroku)
|
|
9
|
+
$stdout.sync = true
|
|
10
|
+
|
|
11
|
+
config_file = nil
|
|
12
|
+
OptionParser.new do |opts|
|
|
13
|
+
opts.banner = 'Usage: debounced-server [--config FILE]'
|
|
14
|
+
opts.on('--config FILE', 'Ruby file that calls Debounced.configure') { |file| config_file = file }
|
|
15
|
+
end.parse!
|
|
16
|
+
|
|
17
|
+
load File.expand_path(config_file) if config_file
|
|
18
|
+
|
|
19
|
+
Debounced::Server.new(Debounced.configuration.socket_descriptor).listen
|
data/lib/debounced/version.rb
CHANGED
data/lib/debounced.rb
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
require 'debounced/version'
|
|
2
|
-
require 'debounced/railtie' if defined?(Rails)
|
|
3
2
|
require 'debounced/no_server_error'
|
|
4
3
|
require 'debounced/socket_conflict_error'
|
|
5
4
|
require 'debounced/service_proxy'
|
|
@@ -32,7 +31,7 @@ module Debounced
|
|
|
32
31
|
def logger
|
|
33
32
|
return @logger if defined? @logger
|
|
34
33
|
|
|
35
|
-
SemanticLogger.add_appender(
|
|
34
|
+
SemanticLogger.add_appender(io: $stdout)
|
|
36
35
|
SemanticLogger.default_level = ENV.fetch('LOG_LEVEL', 'info')
|
|
37
36
|
@logger = SemanticLogger['ServiceProxy']
|
|
38
37
|
end
|
metadata
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: debounced
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 4.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Gary Passero
|
|
8
|
-
bindir:
|
|
8
|
+
bindir: exe
|
|
9
9
|
cert_chain: []
|
|
10
10
|
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
@@ -119,46 +119,26 @@ dependencies:
|
|
|
119
119
|
- - "~>"
|
|
120
120
|
- !ruby/object:Gem::Version
|
|
121
121
|
version: '3.0'
|
|
122
|
-
- !ruby/object:Gem::Dependency
|
|
123
|
-
name: debug
|
|
124
|
-
requirement: !ruby/object:Gem::Requirement
|
|
125
|
-
requirements:
|
|
126
|
-
- - "~>"
|
|
127
|
-
- !ruby/object:Gem::Version
|
|
128
|
-
version: '1.0'
|
|
129
|
-
- - ">="
|
|
130
|
-
- !ruby/object:Gem::Version
|
|
131
|
-
version: 1.0.0
|
|
132
|
-
type: :development
|
|
133
|
-
prerelease: false
|
|
134
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
135
|
-
requirements:
|
|
136
|
-
- - "~>"
|
|
137
|
-
- !ruby/object:Gem::Version
|
|
138
|
-
version: '1.0'
|
|
139
|
-
- - ">="
|
|
140
|
-
- !ruby/object:Gem::Version
|
|
141
|
-
version: 1.0.0
|
|
142
122
|
description: Debounce Ruby callbacks across processes through a lightweight Ruby timer
|
|
143
123
|
server
|
|
144
124
|
email:
|
|
145
125
|
- gary@flytedesk.com
|
|
146
|
-
executables:
|
|
126
|
+
executables:
|
|
127
|
+
- debounced-server
|
|
147
128
|
extensions: []
|
|
148
129
|
extra_rdoc_files: []
|
|
149
130
|
files:
|
|
150
131
|
- CHANGELOG.md
|
|
151
132
|
- README.md
|
|
133
|
+
- exe/debounced-server
|
|
152
134
|
- lib/debounced.rb
|
|
153
135
|
- lib/debounced/callback.rb
|
|
154
136
|
- lib/debounced/callbackable.rb
|
|
155
137
|
- lib/debounced/no_server_error.rb
|
|
156
|
-
- lib/debounced/railtie.rb
|
|
157
138
|
- lib/debounced/server.rb
|
|
158
139
|
- lib/debounced/service_proxy.rb
|
|
159
140
|
- lib/debounced/socket_conflict_error.rb
|
|
160
141
|
- lib/debounced/version.rb
|
|
161
|
-
- lib/tasks/debounced.rake
|
|
162
142
|
homepage: https://github.com/Flytedesk/debounced-rb
|
|
163
143
|
licenses:
|
|
164
144
|
- MIT
|
data/lib/debounced/railtie.rb
DELETED
data/lib/tasks/debounced.rake
DELETED