emb 0.4.3.pre6 → 0.5.0.pre1

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.
@@ -26,43 +26,39 @@ module Emb
26
26
  # shaping, per-slice result mapping, and the bounded concurrent fan-out used
27
27
  # by `lazy: :batch`. Extended into Emb by batch.rb.
28
28
  module BatchDispatch
29
- # Script batch items are [client, SCRIPT_ITEM, argv, decode]; embed items are
30
- # [client, model, text, format]. argv is the fully built EMB.EVAL/EMB.EVSHA
31
- # command and argv[3] its text count.
32
- def script_item?(item)
33
- item[1].equal?(SCRIPT_ITEM)
34
- end
35
-
36
- def item_model(item)
37
- script_item?(item) ? item[2][1] : item[1]
38
- end
39
-
40
- def item_text_count(item)
41
- script_item?(item) ? item[2][3].to_i : Array(item[2]).size
42
- end
43
-
44
- # :batch shares: per-model chunked EMB shares plus one share per script
45
- # call. group_by preserves first-deferral order of the models.
46
- def batch_shares(embeds, scripts, chunk)
29
+ # :batch shares: per-model chunked EMB shares, one or more EMB.IMG shares
30
+ # per compatible image group, plus one share per script call. group_by
31
+ # preserves first-deferral order of the models.
32
+ def batch_shares(embeds, scripts, images, chunk)
47
33
  slices = []
48
34
  embeds.group_by { |item| item[1] }.each_value { |group| slices.concat(pack_slices(group, chunk)) }
35
+ slices.concat(ImageBatch.shares(images))
49
36
  scripts.each { |item| slices << [item] }
50
37
  slices
51
38
  end
52
39
 
53
- # Serial dispatch: one share in flight at a time. Redis errors fail closed
54
- # with context; anything else is a local bug and is re-raised unchanged
55
- # after the pending set is dropped.
56
- def dispatch_serial(client, slices, loader)
40
+ # Serial dispatch: one share in flight at a time. A redis failure is
41
+ # collected per slice so the window's other shares still dispatch; a
42
+ # non-redis error is a local bug and is re-raised unchanged after the
43
+ # pending set is dropped. `single_client` marks a window with nothing else
44
+ # to deliver: an all-failed group keeps the fail-closed contract, and the
45
+ # raise happens here, inside the batch span, so the span records the error.
46
+ def dispatch_serial(client, slices, loader, durations, single_client: false)
47
+ failures = []
57
48
  slices.each do |slice|
58
- resolve_slice(loader, slice, dispatch_slice(client, slice))
49
+ status, _, result, elapsed = dispatch_share(client, slice, Emb::Telemetry.current_context)
50
+ durations << elapsed
51
+ raise result if status == :error
52
+
53
+ resolve_slice(loader, slice, result)
59
54
  rescue RedisClient::Error => e
60
- clear_batch_pending!
61
- raise batch_error(e, slice: slice, budget: retry_budget(client))
55
+ failures << [e, slice, client]
62
56
  rescue StandardError
63
57
  clear_batch_pending!
64
58
  raise
65
59
  end
60
+ fail_closed(failures) if single_client && failures.size == slices.size
61
+ failures
66
62
  end
67
63
 
68
64
  # Sends one chunk share and returns the raw reply entries. Single-model
@@ -75,9 +71,19 @@ module Emb
75
71
  # not be Array()-wrapped into pairs).
76
72
  return client.send_command(*slice.first[2]) if script_item?(slice.first)
77
73
 
74
+ # A one-image EMB.IMG replies with one keyed map, several with an array of
75
+ # maps; resolve expects one entry per image in both cases.
76
+ if image_item?(slice.first)
77
+ reply = client.send_command(*ImageBatch.args(slice))
78
+ return slice.sum { |item| item[3].size } == 1 ? [reply] : Array(reply)
79
+ end
80
+
81
+ Array(client.send_command(*embed_slice_args(slice)))
82
+ end
83
+
84
+ def embed_slice_args(slice)
78
85
  models = slice.map { |_, model, _, _| model }.uniq
79
- args = models.size == 1 ? same_model_args(slice, models.first) : mixed_model_args(slice)
80
- Array(client.send_command(*args))
86
+ models.size == 1 ? same_model_args(slice, models.first) : mixed_model_args(slice)
81
87
  end
82
88
 
83
89
  def same_model_args(slice, model)
@@ -102,9 +108,8 @@ module Emb
102
108
  # items created before the format slot existed default to :binary.
103
109
  def slice_format(slice)
104
110
  formats = slice.map { |item| item[3] }.uniq
105
- if formats.size > 1
106
- raise ArgumentError, "cannot mix :binary and :values formats in one batch"
107
- end
111
+ raise ArgumentError, 'cannot mix :binary and :values formats in one batch' if formats.size > 1
112
+
108
113
  formats.first || :binary
109
114
  end
110
115
 
@@ -116,31 +121,32 @@ module Emb
116
121
  # retry).
117
122
  def resolve_slice(loader, slice, results)
118
123
  return resolve_script_slice(loader, slice.first, results) if script_item?(slice.first)
124
+ return ImageBatch.resolve(loader, slice, results) if image_item?(slice.first)
125
+ return ValuesBatch.resolve(loader, slice, results) if slice_format(slice) == :values
119
126
 
120
- if slice_format(slice) == :values
121
- return ValuesBatch.resolve(loader, slice, results)
122
- end
123
-
124
- expected = slice.sum { |_, _, text, _| Array(text).size }
125
- unless results.size >= expected
126
- raise ShortReplyError, "expected #{expected} reply entries, got #{results.size}"
127
- end
127
+ resolve_entries(loader, slice, results)
128
+ end
128
129
 
130
+ def resolve_entries(loader, slice, results)
131
+ expect_reply_size!(slice, results.size)
129
132
  offset = 0
130
133
  slice.each do |item|
131
- _, _, text, _ = item
132
- texts = Array(text)
133
- values = entry_values(results, offset, texts)
134
+ texts = Array(item[2])
135
+ values = results[offset, texts.size].map { |entry| entry&.unpack('e*') }
134
136
  offset += texts.size
135
137
 
136
138
  # eager Proxy#[] shape: vector for a single text, vectors for many
137
- loader.call(item, values)
139
+ loader.call(item, values.size == 1 ? values.first : values)
140
+ Emb::Telemetry::Deferred.resolve(item)
138
141
  end
139
142
  end
140
143
 
141
- def entry_values(results, offset, texts)
142
- values = results[offset, texts.size].map { |entry| entry&.unpack('e*') }
143
- values.size == 1 ? values.first : values
144
+ # A reply shorter than the slice's texts is a protocol violation.
145
+ def expect_reply_size!(slice, got)
146
+ expected = slice.sum { |_, _, text, _| Array(text).size }
147
+ return if got >= expected
148
+
149
+ raise ShortReplyError, "expected #{expected} reply entries, got #{got}"
144
150
  end
145
151
 
146
152
  # A script call is always a singleton slice; its reply is parsed on the
@@ -148,25 +154,46 @@ module Emb
148
154
  def resolve_script_slice(loader, item, results)
149
155
  multi = item[2][3].to_i > 1
150
156
  loader.call(item, ScriptReplyDecode.parse_script_reply(results, multi: multi, decode: item[3]))
157
+ Emb::Telemetry::Deferred.resolve(item)
151
158
  end
152
159
 
153
160
  # The worker captures failures as outcomes; only the forcing thread
154
- # resolves loaders (see resolve_slice).
155
- def dispatch_share(client, slice)
156
- [:ok, slice, dispatch_slice(client, slice)]
157
- rescue StandardError => e
158
- [:error, slice, e]
161
+ # resolves loaders (see resolve_slice). The share's span is opened and
162
+ # closed here, inside the batch's context: a worker thread starts with an
163
+ # empty one. An elapsed time is appended to the outcome for the batch's
164
+ # parallelism.
165
+ def dispatch_share(client, slice, context)
166
+ Emb::Telemetry.in_flight(1)
167
+ started = Process.clock_gettime(Process::CLOCK_MONOTONIC)
168
+ span = Emb::Telemetry.start_span(Emb::Telemetry::SPAN_SHARE, kind: :client,
169
+ attributes: share_attributes(slice), parent: context)
170
+ outcome = begin
171
+ [:ok, slice, dispatch_slice(client, slice)]
172
+ rescue StandardError => e
173
+ Emb::Telemetry.fail_span(span, e)
174
+ [:error, slice, e]
175
+ end
176
+ outcome << Emb::Telemetry.end_share(span, Process.clock_gettime(Process::CLOCK_MONOTONIC) - started,
177
+ attributes: share_attributes(slice),
178
+ instance: Emb::ConnectionRouter.last_instance)
179
+ ensure
180
+ Emb::Telemetry.in_flight(-1)
181
+ end
182
+
183
+ def share_attributes(slice)
184
+ Emb::Telemetry.share_attributes(slice.map { |item| item_model(item) }.uniq,
185
+ slice.sum { |item| item_text_count(item) })
159
186
  end
160
187
 
161
188
  # Dispatches all shares concurrently over at most the client's connection
162
189
  # capacity workers, then resolves the outcomes (isolating a failed share's
163
190
  # error to its own items).
164
- def dispatch_parallel(client, slices, loader)
191
+ def dispatch_parallel(client, slices, loader, durations)
165
192
  workers = slices.size.clamp(1, worker_capacity(client))
166
193
  queue = share_queue(slices, workers)
167
194
  outcomes = Array.new(slices.size)
168
- run_worker_threads(client, queue, outcomes, workers)
169
- resolve_outcomes(client, outcomes, loader)
195
+ run_worker_threads(client, queue, outcomes, workers, Emb::Telemetry.current_context)
196
+ resolve_outcomes(client, outcomes, loader, durations)
170
197
  end
171
198
 
172
199
  def share_queue(slices, workers)
@@ -182,12 +209,12 @@ module Emb
182
209
  client.pools.sum { |pool| pool.respond_to?(:size) ? pool.size : 1 }
183
210
  end
184
211
 
185
- def run_worker_threads(client, queue, outcomes, workers)
212
+ def run_worker_threads(client, queue, outcomes, workers, context)
186
213
  workers.times.map do
187
214
  Thread.new do
188
215
  while (job = queue.pop)
189
216
  index, slice = job
190
- outcomes[index] = dispatch_share(client, slice)
217
+ outcomes[index] = dispatch_share(client, slice, context)
191
218
  end
192
219
  end
193
220
  end.each(&:join)
@@ -200,9 +227,10 @@ module Emb
200
227
  # prunes the pending items itself once the block returns. Non-redis errors
201
228
  # are local bugs: resolve the other shares, then clear the pending set and
202
229
  # re-raise the first one.
203
- def resolve_outcomes(client, outcomes, loader)
230
+ def resolve_outcomes(client, outcomes, loader, durations)
204
231
  first_error = nil
205
- outcomes.each do |status, slice, result|
232
+ outcomes.each do |status, slice, result, elapsed|
233
+ durations << elapsed if elapsed
206
234
  error = outcome_error(loader, status, slice, result)
207
235
  next unless error
208
236
 
@@ -234,7 +262,10 @@ module Emb
234
262
  # message/context and cause identical for all of the share's items.
235
263
  def fail_share(loader, slice, error, client)
236
264
  poison = batch_error(error, slice: slice, budget: retry_budget(client))
237
- slice.each { |item| loader.call(item, FailedShare.new(poison)) }
265
+ slice.each do |item|
266
+ Emb::Telemetry::Deferred.resolve(item, error: poison)
267
+ loader.call(item, FailedShare.new(poison))
268
+ end
238
269
  end
239
270
 
240
271
  # Packs items into shares by accumulated text count so one command stays
@@ -14,6 +14,7 @@ module Emb
14
14
  def self.wrap
15
15
  yield
16
16
  ensure
17
+ Emb::Telemetry::Deferred.flush
17
18
  BatchLoader::Executor.clear_current
18
19
  end
19
20
  end
data/lib/emb/client.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative 'connection_router'
4
+ require_relative 'image_command'
4
5
  require 'redis_client'
5
6
 
6
7
  module Emb
@@ -14,6 +15,7 @@ module Emb
14
15
  cfg = Emb.configuration
15
16
  @lazy_mode = lazy.nil? ? cfg.lazy : validate_lazy!(lazy)
16
17
  @batch_size = redis_options.delete(:batch_size) || cfg.batch_size
18
+ @max_image_batch_bytes = image_batch_bytes(redis_options, cfg)
17
19
  url = extract_url!(redis_options, cfg)
18
20
  # Captured before ConnectionRouter consumes the merged options, so
19
21
  # fail-closed batches can report the retry budget (Emb::ServerError).
@@ -27,7 +29,7 @@ module Emb
27
29
 
28
30
  def pools = @router.pools
29
31
 
30
- attr_reader :batch_size, :lazy_mode, :reconnect_attempts
32
+ attr_reader :batch_size, :lazy_mode, :reconnect_attempts, :max_image_batch_bytes
31
33
 
32
34
  def [](name)
33
35
  @registry[name] ||= Proxy.new(self, name.to_sym)
@@ -88,6 +90,12 @@ module Emb
88
90
 
89
91
  private
90
92
 
93
+ def image_batch_bytes(opts, cfg)
94
+ value = opts.delete(:max_image_batch_bytes) || cfg.max_image_batch_bytes
95
+ Configuration.validate_image_batch_bytes!(value)
96
+ value
97
+ end
98
+
91
99
  def validate_lazy!(value)
92
100
  unless Configuration::LAZY_MODES.include?(value)
93
101
  raise ArgumentError, "lazy must be false, :multi, or :batch (got #{value.inspect})"
@@ -99,7 +107,7 @@ module Emb
99
107
  # Per-call protocol: bypasses Configuration#protocol=, so validate here too.
100
108
  def merged_redis_options(opts, cfg, url)
101
109
  defaults = cfg.to_h
102
- keys = defaults.keys - %i[url pool lazy batch_size]
110
+ keys = defaults.keys - %i[url pool lazy batch_size max_image_batch_bytes]
103
111
  keys -= %i[host port] if url
104
112
 
105
113
  keys.each do |key|
@@ -0,0 +1,387 @@
1
+ {
2
+ "contract": 1,
3
+ "commands": [
4
+ {
5
+ "name": "AUTH",
6
+ "summary": "Authenticate the connection when a password is configured.",
7
+ "grammar": "AUTH \u003cpassword\u003e",
8
+ "keywords": [],
9
+ "arity": {
10
+ "min": 1,
11
+ "tail": "none"
12
+ },
13
+ "flags": [
14
+ "introspection"
15
+ ],
16
+ "reply": "OK on success; an error otherwise."
17
+ },
18
+ {
19
+ "name": "CLIENT",
20
+ "summary": "Answer the CLIENT subcommands RESP3 client handshakes send.",
21
+ "grammar": "CLIENT SETINFO \u003cname\u003e \u003cvalue\u003e",
22
+ "keywords": [
23
+ "SETINFO"
24
+ ],
25
+ "arity": {
26
+ "min": 1,
27
+ "tail": "none"
28
+ },
29
+ "flags": [
30
+ "introspection"
31
+ ],
32
+ "reply": "OK for CLIENT SETINFO; an error for unknown subcommands."
33
+ },
34
+ {
35
+ "name": "CONFIG",
36
+ "summary": "Read or live-tune runtime configuration parameters.",
37
+ "grammar": "CONFIG GET [pattern] | CONFIG SET \u003cparam\u003e \u003cvalue\u003e",
38
+ "keywords": [
39
+ "GET",
40
+ "SET"
41
+ ],
42
+ "arity": {
43
+ "min": 1,
44
+ "tail": "none"
45
+ },
46
+ "flags": [
47
+ "changes-config"
48
+ ],
49
+ "reply": "GET replies with flat name/value pairs; SET replies OK or an error."
50
+ },
51
+ {
52
+ "name": "EMB",
53
+ "summary": "Generate embeddings for one or more texts of one model.",
54
+ "grammar": "EMB \u003cmodel\u003e [BLOB|VALUES] \u003ctext\u003e [text...]",
55
+ "keywords": [
56
+ "BLOB",
57
+ "VALUES"
58
+ ],
59
+ "arity": {
60
+ "min": 2,
61
+ "tail": "variadic"
62
+ },
63
+ "flags": [
64
+ "inference"
65
+ ],
66
+ "reply": "One text: a bulk string of float32 bytes (BLOB) or a VALUES envelope. Several texts under BLOB: an array of the same in request order. Several texts under VALUES: one envelope with shape [count, dim]."
67
+ },
68
+ {
69
+ "name": "EMB.CACHE.FLUSH",
70
+ "summary": "Invalidate all cached embeddings, or one model's.",
71
+ "grammar": "EMB.CACHE.FLUSH [model]",
72
+ "keywords": [],
73
+ "arity": {
74
+ "min": 0,
75
+ "tail": "none"
76
+ },
77
+ "flags": [
78
+ "writes-state"
79
+ ],
80
+ "reply": "Integer count of removed entries."
81
+ },
82
+ {
83
+ "name": "EMB.EVAL",
84
+ "summary": "Evaluate a Lua script once against a model.",
85
+ "grammar": "EMB.EVAL \u003cmodel\u003e \u003cscript\u003e \u003cnumtexts\u003e \u003ctext...\u003e \u003carg...\u003e",
86
+ "keywords": [],
87
+ "arity": {
88
+ "min": 3,
89
+ "tail": "variadic"
90
+ },
91
+ "flags": [
92
+ "inference"
93
+ ],
94
+ "reply": "The script's converted value, or an array of values for several texts."
95
+ },
96
+ {
97
+ "name": "EMB.EVSHA",
98
+ "summary": "Evaluate a cached script by SHA1.",
99
+ "grammar": "EMB.EVSHA \u003cmodel\u003e \u003csha\u003e \u003cnumtexts\u003e \u003ctext...\u003e \u003carg...\u003e",
100
+ "keywords": [],
101
+ "arity": {
102
+ "min": 3,
103
+ "tail": "variadic"
104
+ },
105
+ "flags": [
106
+ "inference"
107
+ ],
108
+ "reply": "The script's converted value, or an array of values for several texts."
109
+ },
110
+ {
111
+ "name": "EMB.HELP",
112
+ "summary": "Show the command reference, including the script surface.",
113
+ "grammar": "EMB.HELP",
114
+ "keywords": [],
115
+ "arity": {
116
+ "min": 0,
117
+ "tail": "none"
118
+ },
119
+ "flags": [
120
+ "introspection"
121
+ ],
122
+ "reply": "A bulk string of help lines."
123
+ },
124
+ {
125
+ "name": "EMB.IMG",
126
+ "summary": "Embed one or more raw encoded images of one model.",
127
+ "grammar": "EMB.IMG \u003cmodel\u003e [BLOB|VALUES] [OUTPUTS \u003cname\u003e[,\u003cname\u003e...]] \u003cimage-bytes\u003e [\u003cimage-bytes\u003e...]",
128
+ "keywords": [
129
+ "BLOB",
130
+ "VALUES",
131
+ "OUTPUTS"
132
+ ],
133
+ "arity": {
134
+ "min": 2,
135
+ "tail": "variadic"
136
+ },
137
+ "flags": [
138
+ "inference"
139
+ ],
140
+ "reply": "One image: a keyed map of output name to value; several: an array of such maps in request order, with null for a failed or truncated slot.",
141
+ "reply_schema": {
142
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
143
+ "oneOf": [
144
+ {
145
+ "type": "null",
146
+ "description": "one image that failed or was truncated"
147
+ },
148
+ {
149
+ "type": "object",
150
+ "description": "one image: output name to that output's value"
151
+ },
152
+ {
153
+ "type": "array",
154
+ "description": "several images, one keyed map per image in request order",
155
+ "items": {
156
+ "oneOf": [
157
+ {
158
+ "type": "object"
159
+ },
160
+ {
161
+ "type": "null"
162
+ }
163
+ ]
164
+ }
165
+ }
166
+ ]
167
+ },
168
+ "wire_notes": "RESP2 writes each map as a flat alternating name/value array; RESP3 writes a map. VALUES replaces each bulk string with a dtype/shape/values envelope."
169
+ },
170
+ {
171
+ "name": "EMB.IMGMULTI",
172
+ "summary": "Embed images across different models in one call.",
173
+ "grammar": "EMB.IMGMULTI [BLOB|VALUES] [OUTPUTS \u003cname\u003e[,\u003cname\u003e...]] \u003cmodel\u003e \u003cimage-bytes\u003e [\u003cmodel\u003e \u003cimage-bytes\u003e...]",
174
+ "keywords": [
175
+ "BLOB",
176
+ "VALUES",
177
+ "OUTPUTS"
178
+ ],
179
+ "arity": {
180
+ "min": 2,
181
+ "tail": "even-pairs"
182
+ },
183
+ "flags": [
184
+ "inference"
185
+ ],
186
+ "reply": "An array with one keyed map per pair in request order; a failed pair is null; under VALUES each pair carries its model beside its outputs.",
187
+ "reply_schema": {
188
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
189
+ "type": "array",
190
+ "description": "one keyed map per model/image pair in request order",
191
+ "items": {
192
+ "oneOf": [
193
+ {
194
+ "type": "object"
195
+ },
196
+ {
197
+ "type": "null"
198
+ }
199
+ ]
200
+ }
201
+ },
202
+ "wire_notes": "RESP2 writes each map as a flat alternating name/value array; RESP3 writes a map. VALUES replaces each bulk string with a dtype/shape/values envelope."
203
+ },
204
+ {
205
+ "name": "EMB.INFO",
206
+ "summary": "Show one model's configuration and statistics.",
207
+ "grammar": "EMB.INFO \u003cmodel\u003e",
208
+ "keywords": [],
209
+ "arity": {
210
+ "min": 1,
211
+ "tail": "none"
212
+ },
213
+ "flags": [
214
+ "introspection"
215
+ ],
216
+ "reply": "A map of model fields: dim, workers, latency, CPU plan, embed/image/script phases, image outputs, and cache stats."
217
+ },
218
+ {
219
+ "name": "EMB.MODELS",
220
+ "summary": "List loaded models with dimensions and status.",
221
+ "grammar": "EMB.MODELS",
222
+ "keywords": [],
223
+ "arity": {
224
+ "min": 0,
225
+ "tail": "none"
226
+ },
227
+ "flags": [
228
+ "introspection"
229
+ ],
230
+ "reply": "RESP2: an array of [name, dim, status]; RESP3: a map keyed by model name with dim and status."
231
+ },
232
+ {
233
+ "name": "EMB.MULTI",
234
+ "summary": "Embed texts across different models in one round trip.",
235
+ "grammar": "EMB.MULTI [BLOB|VALUES] \u003cmodel\u003e \u003ctext\u003e [\u003cmodel\u003e \u003ctext\u003e...]",
236
+ "keywords": [
237
+ "BLOB",
238
+ "VALUES"
239
+ ],
240
+ "arity": {
241
+ "min": 2,
242
+ "tail": "even-pairs"
243
+ },
244
+ "flags": [
245
+ "inference"
246
+ ],
247
+ "reply": "An array with one vector (or VALUES envelope) per pair in request order; a failed pair is null."
248
+ },
249
+ {
250
+ "name": "EMB.READY",
251
+ "summary": "Report server readiness.",
252
+ "grammar": "EMB.READY",
253
+ "keywords": [],
254
+ "arity": {
255
+ "min": 0,
256
+ "tail": "none"
257
+ },
258
+ "flags": [
259
+ "introspection"
260
+ ],
261
+ "reply": "+OK when ready; an error naming loading, draining, or no models."
262
+ },
263
+ {
264
+ "name": "EMB.SAVE",
265
+ "summary": "Accept an asynchronous cache snapshot.",
266
+ "grammar": "EMB.SAVE",
267
+ "keywords": [],
268
+ "arity": {
269
+ "min": 0,
270
+ "tail": "none"
271
+ },
272
+ "flags": [
273
+ "writes-state"
274
+ ],
275
+ "reply": "OK once the snapshot is accepted; an error when persistence is disabled or disallowed."
276
+ },
277
+ {
278
+ "name": "EMB.SCRIPT",
279
+ "summary": "Compile, inspect, and flush cached Lua scripts.",
280
+ "grammar": "EMB.SCRIPT LOAD \u003cmodel\u003e \u003cscript\u003e | EMB.SCRIPT EXISTS \u003cmodel\u003e \u003csha...\u003e | EMB.SCRIPT FLUSH [\u003cmodel\u003e]",
281
+ "keywords": [
282
+ "LOAD",
283
+ "EXISTS",
284
+ "FLUSH"
285
+ ],
286
+ "arity": {
287
+ "min": 1,
288
+ "tail": "none"
289
+ },
290
+ "flags": [
291
+ "writes-state"
292
+ ],
293
+ "reply": "LOAD replies a bulk SHA1; EXISTS replies an array of 1/0 per SHA; FLUSH replies OK."
294
+ },
295
+ {
296
+ "name": "EMB.STATS",
297
+ "summary": "Show server-wide statistics.",
298
+ "grammar": "EMB.STATS",
299
+ "keywords": [],
300
+ "arity": {
301
+ "min": 0,
302
+ "tail": "none"
303
+ },
304
+ "flags": [
305
+ "introspection"
306
+ ],
307
+ "reply": "A map of uptime, requests, per-model breakdown, CPU, cache, connections, memory, and goroutines."
308
+ },
309
+ {
310
+ "name": "HELLO",
311
+ "summary": "Negotiate the RESP protocol version for the connection.",
312
+ "grammar": "HELLO [2|3]",
313
+ "keywords": [],
314
+ "arity": {
315
+ "min": 0,
316
+ "tail": "none"
317
+ },
318
+ "flags": [
319
+ "introspection"
320
+ ],
321
+ "reply": "A map (flat array under RESP2) with server, version, proto, mode, and role."
322
+ },
323
+ {
324
+ "name": "INFO",
325
+ "summary": "Show Redis-style server information sections.",
326
+ "grammar": "INFO [section...]",
327
+ "keywords": [],
328
+ "arity": {
329
+ "min": 0,
330
+ "tail": "variadic"
331
+ },
332
+ "flags": [
333
+ "introspection"
334
+ ],
335
+ "reply": "A bulk string of CRLF-separated sections."
336
+ },
337
+ {
338
+ "name": "MONITOR",
339
+ "summary": "Show recent completed request events.",
340
+ "grammar": "MONITOR [seq] [limit]",
341
+ "keywords": [],
342
+ "arity": {
343
+ "min": 0,
344
+ "tail": "none"
345
+ },
346
+ "flags": [
347
+ "introspection",
348
+ "exposes-traffic"
349
+ ],
350
+ "reply": "An array of events, each a 12-field flat array under RESP2 or a map under RESP3; no text payloads."
351
+ },
352
+ {
353
+ "name": "PING",
354
+ "summary": "Redis compatibility ping.",
355
+ "grammar": "PING",
356
+ "keywords": [],
357
+ "arity": {
358
+ "min": 0,
359
+ "tail": "none"
360
+ },
361
+ "flags": [
362
+ "introspection"
363
+ ],
364
+ "reply": "Simple string PONG."
365
+ },
366
+ {
367
+ "name": "SHUTDOWN",
368
+ "summary": "Stop the server with Redis's shutdown semantics.",
369
+ "grammar": "SHUTDOWN [NOSAVE|SAVE] [NOW] [FORCE] [ABORT]",
370
+ "keywords": [
371
+ "NOSAVE",
372
+ "SAVE",
373
+ "NOW",
374
+ "FORCE",
375
+ "ABORT"
376
+ ],
377
+ "arity": {
378
+ "min": 0,
379
+ "tail": "none"
380
+ },
381
+ "flags": [
382
+ "terminates-server"
383
+ ],
384
+ "reply": "No reply: the caller blocks and the connection closes. SHUTDOWN ABORT replies OK or an error."
385
+ }
386
+ ]
387
+ }