async-redis 0.8.0 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/async/redis/client.rb +6 -7
- data/lib/async/redis/protocol/resp2.rb +2 -2
- data/lib/async/redis/sentinels.rb +7 -5
- data/lib/async/redis/version.rb +1 -1
- data/license.md +1 -1
- data/readme.md +11 -100
- data.tar.gz.sig +0 -0
- metadata +26 -11
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c61c1f4d04e59d7a09f58429a04438e674d7839bc6d6411b3fc33668d4068c4b
|
4
|
+
data.tar.gz: f13579f444972e6b5a7d1388f37d20d74978e867130b5cdad303e829905a6ca6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99b7e9bb4091f09a6b51a1216a44b69ebd63918df6755d447f327b69bdf148cbf91e7a1b1a5adbe75ccff93f36be93cdf0d5034bed624743fcac23524d285df7
|
7
|
+
data.tar.gz: f9afbc599da80472df731cb370c77422184c3a41a4ab0efd0df638fad31f9a68fa7cde775d7451826cf781c1d29e9c86d3d27c0a94a6b1605b121dd33dddd13f
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/async/redis/client.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2018-
|
4
|
+
# Copyright, 2018-2024, by Samuel Williams.
|
5
5
|
# Copyright, 2018, by Huba Nagy.
|
6
6
|
# Copyright, 2019, by Mikael Henriksson.
|
7
7
|
# Copyright, 2019, by David Ortiz.
|
@@ -10,22 +10,21 @@
|
|
10
10
|
require_relative 'context/pipeline'
|
11
11
|
require_relative 'context/transaction'
|
12
12
|
require_relative 'context/subscribe'
|
13
|
-
|
14
13
|
require_relative 'protocol/resp2'
|
15
14
|
|
16
|
-
require '
|
17
|
-
require 'async/io/stream'
|
15
|
+
require 'io/endpoint/host_endpoint'
|
18
16
|
require 'async/pool/controller'
|
19
|
-
|
20
17
|
require 'protocol/redis/methods'
|
21
18
|
|
19
|
+
require 'io/stream'
|
20
|
+
|
22
21
|
module Async
|
23
22
|
module Redis
|
24
23
|
# Legacy.
|
25
24
|
ServerError = ::Protocol::Redis::ServerError
|
26
25
|
|
27
26
|
def self.local_endpoint(port: 6379)
|
28
|
-
|
27
|
+
::IO::Endpoint.tcp('localhost', port)
|
29
28
|
end
|
30
29
|
|
31
30
|
class Client
|
@@ -121,7 +120,7 @@ module Async
|
|
121
120
|
# We will manage flushing ourselves:
|
122
121
|
peer.sync = true
|
123
122
|
|
124
|
-
stream = IO::Stream
|
123
|
+
stream = ::IO::Stream(peer)
|
125
124
|
|
126
125
|
@protocol.client(stream)
|
127
126
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2018-
|
4
|
+
# Copyright, 2018-2024, by Samuel Williams.
|
5
5
|
|
6
6
|
require 'protocol/redis'
|
7
7
|
|
@@ -15,7 +15,7 @@ module Async
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def viable?
|
18
|
-
@stream.
|
18
|
+
@stream.readable?
|
19
19
|
end
|
20
20
|
|
21
21
|
def reusable?
|
@@ -2,7 +2,9 @@
|
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
4
|
# Copyright, 2020, by David Ortiz.
|
5
|
-
# Copyright, 2023, by Samuel Williams.
|
5
|
+
# Copyright, 2023-2024, by Samuel Williams.
|
6
|
+
|
7
|
+
require 'io/stream'
|
6
8
|
|
7
9
|
module Async
|
8
10
|
module Redis
|
@@ -10,7 +12,7 @@ module Async
|
|
10
12
|
def initialize(master_name, sentinels, role = :master, protocol = Protocol::RESP2, **options)
|
11
13
|
@master_name = master_name
|
12
14
|
@sentinel_endpoints = sentinels.map do |sentinel|
|
13
|
-
|
15
|
+
::IO::Endpoint.tcp(sentinel[:host], sentinel[:port])
|
14
16
|
end
|
15
17
|
@role = role
|
16
18
|
|
@@ -26,7 +28,7 @@ module Async
|
|
26
28
|
Async::Pool::Controller.wrap(**options) do
|
27
29
|
endpoint = resolve_address
|
28
30
|
peer = endpoint.connect
|
29
|
-
stream = IO::Stream
|
31
|
+
stream = ::IO::Stream(peer)
|
30
32
|
|
31
33
|
@protocol.client(stream)
|
32
34
|
end
|
@@ -52,7 +54,7 @@ module Async
|
|
52
54
|
next
|
53
55
|
end
|
54
56
|
|
55
|
-
return
|
57
|
+
return ::IO::Endpoint.tcp(address[0], address[1]) if address
|
56
58
|
end
|
57
59
|
|
58
60
|
nil
|
@@ -72,7 +74,7 @@ module Async
|
|
72
74
|
next if slaves.empty?
|
73
75
|
|
74
76
|
slave = select_slave(slaves)
|
75
|
-
return
|
77
|
+
return ::IO::Endpoint.tcp(slave['ip'], slave['port'])
|
76
78
|
end
|
77
79
|
|
78
80
|
nil
|
data/lib/async/redis/version.rb
CHANGED
data/license.md
CHANGED
data/readme.md
CHANGED
@@ -1,111 +1,14 @@
|
|
1
1
|
# Async::Redis
|
2
2
|
|
3
|
-
An asynchronous client for Redis including TLS. Support for streaming requests and responses. Built on top of [async](https://github.com/socketry/async)
|
3
|
+
An asynchronous client for Redis including TLS. Support for streaming requests and responses. Built on top of [async](https://github.com/socketry/async).
|
4
4
|
|
5
5
|
[![Development Status](https://github.com/socketry/async-redis/workflows/Test/badge.svg)](https://github.com/socketry/async-redis/actions?workflow=Test)
|
6
6
|
|
7
|
-
## Installation
|
8
|
-
|
9
|
-
``` shell
|
10
|
-
$ bundle add async-redis
|
11
|
-
```
|
12
|
-
|
13
7
|
## Usage
|
14
8
|
|
15
|
-
|
16
|
-
|
17
|
-
``` ruby
|
18
|
-
require 'async/redis'
|
19
|
-
|
20
|
-
endpoint = Async::Redis.local_endpoint
|
21
|
-
client = Async::Redis::Client.new(endpoint)
|
22
|
-
|
23
|
-
Async do
|
24
|
-
pp client.info
|
25
|
-
ensure
|
26
|
-
client.close
|
27
|
-
end
|
28
|
-
```
|
29
|
-
|
30
|
-
### Connecting to Redis SSL Endpoint
|
31
|
-
|
32
|
-
This example demonstrates parsing an environment variable with a `redis://` or SSL `rediss://` scheme, and demonstrates how you can specify SSL parameters on the SSLContext object.
|
33
|
-
|
34
|
-
``` ruby
|
35
|
-
require 'async/redis'
|
36
|
-
|
37
|
-
def make_redis_endpoint(uri)
|
38
|
-
tcp_endpoint = Async::IO::Endpoint.tcp(uri.hostname, uri.port)
|
39
|
-
case uri.scheme
|
40
|
-
when 'redis'
|
41
|
-
tcp_endpoint
|
42
|
-
when 'rediss'
|
43
|
-
ssl_context = OpenSSL::SSL::SSLContext.new
|
44
|
-
ssl_context.set_params(
|
45
|
-
ca_file: "/path/to/ca.crt",
|
46
|
-
cert: OpenSSL::X509::Certificate.new(File.read("client.crt")),
|
47
|
-
key: OpenSSL::PKey::RSA.new(File.read("client.key")),
|
48
|
-
)
|
49
|
-
Async::IO::SSLEndpoint.new(tcp_endpoint, ssl_context: ssl_context)
|
50
|
-
else
|
51
|
-
raise ArgumentError
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
endpoint = make_redis_endpoint(URI(ENV['REDIS_URL']))
|
56
|
-
client = Async::Redis::Client.new(endpoint)
|
57
|
-
|
58
|
-
# ...
|
59
|
-
```
|
9
|
+
Please see the [project documentation](https://github.com/socketry/async-redis) for more details.
|
60
10
|
|
61
|
-
|
62
|
-
|
63
|
-
``` ruby
|
64
|
-
require 'async'
|
65
|
-
require 'async/redis'
|
66
|
-
|
67
|
-
endpoint = Async::Redis.local_endpoint
|
68
|
-
client = Async::Redis::Client.new(endpoint)
|
69
|
-
|
70
|
-
Async do
|
71
|
-
client.set('X', 10)
|
72
|
-
pp client.get('X')
|
73
|
-
ensure
|
74
|
-
client.close
|
75
|
-
end
|
76
|
-
```
|
77
|
-
|
78
|
-
### Subscriptions
|
79
|
-
|
80
|
-
``` ruby
|
81
|
-
require 'async'
|
82
|
-
require 'async/redis'
|
83
|
-
|
84
|
-
endpoint = Async::Redis.local_endpoint
|
85
|
-
client = Async::Redis::Client.new(endpoint)
|
86
|
-
|
87
|
-
Async do |task|
|
88
|
-
condition = Async::Condition.new
|
89
|
-
|
90
|
-
publisher = task.async do
|
91
|
-
condition.wait
|
92
|
-
|
93
|
-
client.publish 'status.frontend', 'good'
|
94
|
-
end
|
95
|
-
|
96
|
-
subscriber = task.async do
|
97
|
-
client.subscribe 'status.frontend' do |context|
|
98
|
-
condition.signal # We are waiting for messages.
|
99
|
-
|
100
|
-
type, name, message = context.listen
|
101
|
-
|
102
|
-
pp type, name, message
|
103
|
-
end
|
104
|
-
end
|
105
|
-
ensure
|
106
|
-
client.close
|
107
|
-
end
|
108
|
-
```
|
11
|
+
- [Getting Started](https://github.com/socketry/async-redisguides/getting-started/index) - This guide explains how to use the `async-redis` gem to connect to a Redis server and perform basic operations.
|
109
12
|
|
110
13
|
## Contributing
|
111
14
|
|
@@ -116,3 +19,11 @@ We welcome contributions to this project.
|
|
116
19
|
3. Commit your changes (`git commit -am 'Add some feature'`).
|
117
20
|
4. Push to the branch (`git push origin my-new-feature`).
|
118
21
|
5. Create new Pull Request.
|
22
|
+
|
23
|
+
### Developer Certificate of Origin
|
24
|
+
|
25
|
+
This project uses the [Developer Certificate of Origin](https://developercertificate.org/). All contributors to this project must agree to this document to have their contributions accepted.
|
26
|
+
|
27
|
+
### Contributor Covenant
|
28
|
+
|
29
|
+
This project is governed by the [Contributor Covenant](https://www.contributor-covenant.org/). All contributors and participants agree to abide by its terms.
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: async-redis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -48,7 +48,7 @@ cert_chain:
|
|
48
48
|
Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
|
49
49
|
voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
|
50
50
|
-----END CERTIFICATE-----
|
51
|
-
date:
|
51
|
+
date: 2024-04-24 00:00:00.000000000 Z
|
52
52
|
dependencies:
|
53
53
|
- !ruby/object:Gem::Dependency
|
54
54
|
name: async
|
@@ -71,33 +71,47 @@ dependencies:
|
|
71
71
|
- !ruby/object:Gem::Version
|
72
72
|
version: '3.0'
|
73
73
|
- !ruby/object:Gem::Dependency
|
74
|
-
name: async-
|
74
|
+
name: async-pool
|
75
75
|
requirement: !ruby/object:Gem::Requirement
|
76
76
|
requirements:
|
77
77
|
- - "~>"
|
78
78
|
- !ruby/object:Gem::Version
|
79
|
-
version: '
|
79
|
+
version: '0.2'
|
80
80
|
type: :runtime
|
81
81
|
prerelease: false
|
82
82
|
version_requirements: !ruby/object:Gem::Requirement
|
83
83
|
requirements:
|
84
84
|
- - "~>"
|
85
85
|
- !ruby/object:Gem::Version
|
86
|
-
version: '
|
86
|
+
version: '0.2'
|
87
87
|
- !ruby/object:Gem::Dependency
|
88
|
-
name:
|
88
|
+
name: io-endpoint
|
89
89
|
requirement: !ruby/object:Gem::Requirement
|
90
90
|
requirements:
|
91
91
|
- - "~>"
|
92
92
|
- !ruby/object:Gem::Version
|
93
|
-
version: '0.
|
93
|
+
version: '0.10'
|
94
94
|
type: :runtime
|
95
95
|
prerelease: false
|
96
96
|
version_requirements: !ruby/object:Gem::Requirement
|
97
97
|
requirements:
|
98
98
|
- - "~>"
|
99
99
|
- !ruby/object:Gem::Version
|
100
|
-
version: '0.
|
100
|
+
version: '0.10'
|
101
|
+
- !ruby/object:Gem::Dependency
|
102
|
+
name: io-stream
|
103
|
+
requirement: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - "~>"
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0.4'
|
108
|
+
type: :runtime
|
109
|
+
prerelease: false
|
110
|
+
version_requirements: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - "~>"
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '0.4'
|
101
115
|
- !ruby/object:Gem::Dependency
|
102
116
|
name: protocol-redis
|
103
117
|
requirement: !ruby/object:Gem::Requirement
|
@@ -133,7 +147,8 @@ files:
|
|
133
147
|
homepage: https://github.com/socketry/async-redis
|
134
148
|
licenses:
|
135
149
|
- MIT
|
136
|
-
metadata:
|
150
|
+
metadata:
|
151
|
+
source_code_uri: https://github.com/socketry/async-redis.git
|
137
152
|
post_install_message:
|
138
153
|
rdoc_options: []
|
139
154
|
require_paths:
|
@@ -142,14 +157,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
142
157
|
requirements:
|
143
158
|
- - ">="
|
144
159
|
- !ruby/object:Gem::Version
|
145
|
-
version: '
|
160
|
+
version: '3.1'
|
146
161
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
147
162
|
requirements:
|
148
163
|
- - ">="
|
149
164
|
- !ruby/object:Gem::Version
|
150
165
|
version: '0'
|
151
166
|
requirements: []
|
152
|
-
rubygems_version: 3.
|
167
|
+
rubygems_version: 3.5.3
|
153
168
|
signing_key:
|
154
169
|
specification_version: 4
|
155
170
|
summary: A Redis client library.
|
metadata.gz.sig
CHANGED
Binary file
|