togul 3.0.0 → 3.0.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/lib/togul/client.rb +8 -3
- data/lib/togul/stream_client.rb +2 -0
- 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: 8b2551b63847f7928914d173351b85f54aa78f64a67552701273b9ef334ea0e2
|
|
4
|
+
data.tar.gz: cb63352498c0f05520963a92fb0f8ea17759b91823a7538d9051134ffd91120b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7272d609f48bd5100c6e9f6bf78b00d0df4bd0a517f1e96a2c097335d6319b66d81f0f7c8485ea3a9307c7868c5ce2c74cc59bee5e8971f4884fc4247a36e843
|
|
7
|
+
data.tar.gz: 359137fd534f9dac13572955a506852ab9baa1d8c6e5a07289312075bb4d12656f3fd1e5c65dbb6df439342e18d41647e040e95a9e43ec5c20769b2010f787c3
|
data/lib/togul/client.rb
CHANGED
|
@@ -39,14 +39,19 @@ module Togul
|
|
|
39
39
|
@cache.invalidate_flag(key)
|
|
40
40
|
end
|
|
41
41
|
|
|
42
|
-
# Start SSE stream for real-time cache invalidation.
|
|
43
|
-
|
|
42
|
+
# Start the SSE stream in a background thread for real-time cache invalidation.
|
|
43
|
+
# Subsequent calls are no-ops; the thread runs until the process exits.
|
|
44
|
+
def start_stream
|
|
44
45
|
@stream_client ||= StreamClient.new(@config, @cache)
|
|
46
|
+
@stream_thread ||= Thread.new { @stream_client.connect }
|
|
47
|
+
nil
|
|
45
48
|
end
|
|
46
49
|
|
|
47
50
|
# Register a listener for cache invalidation events.
|
|
51
|
+
# Call start_stream separately to begin receiving events.
|
|
48
52
|
def on_cache_invalidated(&block)
|
|
49
|
-
|
|
53
|
+
@stream_client ||= StreamClient.new(@config, @cache)
|
|
54
|
+
@stream_client.on_cache_invalidated(&block)
|
|
50
55
|
end
|
|
51
56
|
|
|
52
57
|
private
|
data/lib/togul/stream_client.rb
CHANGED
|
@@ -37,6 +37,8 @@ module Togul
|
|
|
37
37
|
uri = URI("#{@config.base_url}/api/v1/stream")
|
|
38
38
|
http = Net::HTTP.new(uri.host, uri.port)
|
|
39
39
|
http.use_ssl = uri.scheme == 'https'
|
|
40
|
+
http.open_timeout = @config.timeout
|
|
41
|
+
http.read_timeout = nil # SSE is long-lived; no read deadline
|
|
40
42
|
|
|
41
43
|
request = Net::HTTP::Get.new(uri.path)
|
|
42
44
|
request['Accept'] = 'text/event-stream'
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: togul
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.0.
|
|
4
|
+
version: 3.0.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Togul
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-05-
|
|
11
|
+
date: 2026-05-23 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: json
|