Unverified Commit 4ba47d2d authored by guybe7's avatar guybe7 Committed by GitHub
Browse files

Add reply_schema to command json files (internal for now) (#10273)

Work in progress towards implementing a reply schema as part of COMMAND DOCS, see #9845
Since ironing the details of the reply schema of each and every command can take a long time, we
would like to merge this PR when the infrastructure is ready, and let this mature in the unstable branch.
Meanwhile the changes of this PR are internal, they are part of the repo, but do not affect the produced build.

### Background
In #9656 we add a lot of information about Redis commands, but we are missing information about the replies

### Motivation
1. Documentation. This is the primary goal.
2. It should be possible, based on the output of COMMAND, to be able to generate client code in typed
  languages. In order to do that, we need Redis to tell us, in detail, what each reply looks like.
3. We would like to build a fuzzer that verifies the reply structure (for now we use the existing
  testsuite, see the "Testing" section)

### Schema...
parent c46d68d6
...@@ -24,6 +24,9 @@ ...@@ -24,6 +24,9 @@
"acl_categories": [ "acl_categories": [
"CONNECTION" "CONNECTION"
], ],
"reply_schema": {
"const": "OK"
},
"arguments": [ "arguments": [
{ {
"name": "username", "name": "username",
......
...@@ -10,6 +10,10 @@ ...@@ -10,6 +10,10 @@
"NO_ASYNC_LOADING", "NO_ASYNC_LOADING",
"ADMIN", "ADMIN",
"NOSCRIPT" "NOSCRIPT"
] ],
"reply_schema": {
"description": "A simple string reply indicating that the rewriting started or is about to start ASAP",
"type": "string"
}
} }
} }
...@@ -25,6 +25,16 @@ ...@@ -25,6 +25,16 @@
"optional": true, "optional": true,
"since": "3.2.2" "since": "3.2.2"
} }
] ],
"reply_schema": {
"oneOf": [
{
"const": "Background saving started"
},
{
"const": "Background saving scheduled"
}
]
}
} }
} }
...@@ -77,6 +77,11 @@ ...@@ -77,6 +77,11 @@
} }
] ]
} }
] ],
"reply_schema": {
"description": "The number of bits set to 1.",
"type": "integer",
"minimum": 0
}
} }
} }
...@@ -139,6 +139,21 @@ ...@@ -139,6 +139,21 @@
} }
] ]
} }
] ],
"reply_schema": {
"type": "array",
"items": {
"oneOf": [
{
"description": "The result of the subcommand at the same position",
"type": "integer"
},
{
"description": "In case OVERFLOW FAIL was given and overflows or underflows detected",
"type": "null"
}
]
}
}
} }
} }
...@@ -57,6 +57,13 @@ ...@@ -57,6 +57,13 @@
} }
] ]
} }
] ],
"reply_schema": {
"type": "array",
"items": {
"description": "The result of the subcommand at the same position",
"type": "integer"
}
}
} }
} }
...@@ -89,6 +89,11 @@ ...@@ -89,6 +89,11 @@
"key_spec_index": 1, "key_spec_index": 1,
"multiple": true "multiple": true
} }
] ],
"reply_schema": {
"description": "the size of the string stored in the destination key, that is equal to the size of the longest input string",
"type": "integer",
"minimum": 0
}
} }
} }
...@@ -88,6 +88,19 @@ ...@@ -88,6 +88,19 @@
} }
] ]
} }
] ],
"reply_schema": {
"oneOf": [
{
"description": "the position of the first bit set to 1 or 0 according to the request",
"type": "integer",
"minimum": 0
},
{
"description": "In case the `bit` argument is 1 and the string is empty or composed of just zero bytes",
"const": -1
}
]
}
} }
} }
...@@ -54,6 +54,18 @@ ...@@ -54,6 +54,18 @@
} }
} }
], ],
"reply_schema": {
"oneOf": [
{
"description": "The popped element.",
"type": "string"
},
{
"description": "Operation timed-out",
"type": "null"
}
]
},
"arguments": [ "arguments": [
{ {
"name": "source", "name": "source",
......
...@@ -35,6 +35,34 @@ ...@@ -35,6 +35,34 @@
} }
} }
], ],
"reply_schema": {
"oneOf": [
{
"description": "Operation timed-out",
"type": "null"
},
{
"description": "The key from which elements were popped and the popped elements",
"type": "array",
"minItems": 2,
"maxItems": 2,
"items": [
{
"description": "List key from which elements were popped.",
"type": "string"
},
{
"description": "Array of popped elements.",
"type": "array",
"minItems": 1,
"items": {
"type": "string"
}
}
]
}
]
},
"arguments": [ "arguments": [
{ {
"name": "timeout", "name": "timeout",
......
...@@ -41,6 +41,30 @@ ...@@ -41,6 +41,30 @@
} }
} }
], ],
"reply_schema": {
"oneOf": [
{
"type": "null",
"description": "No element could be popped and timeout expired"
},
{
"description": "The key from which the element was popped and the value of the popped element",
"type": "array",
"minItems": 2,
"maxItems": 2,
"items": [
{
"description": "List key from which the element was popped.",
"type": "string"
},
{
"description": "Value of the popped element.",
"type": "string"
}
]
}
]
},
"arguments": [ "arguments": [
{ {
"name": "key", "name": "key",
......
...@@ -52,6 +52,29 @@ ...@@ -52,6 +52,29 @@
"name": "timeout", "name": "timeout",
"type": "double" "type": "double"
} }
] ],
"reply_schema": {
"oneOf": [
{
"description": "No element could be popped and the timeout expired.",
"type": "null"
},
{
"type": "array",
"minItems": 2,
"maxItems": 2,
"items": [
{
"description": "The name of the key where an element was popped ",
"type": "string"
},
{
"description": "The value of the popped element",
"type": "string"
}
]
}
]
}
} }
} }
...@@ -65,6 +65,18 @@ ...@@ -65,6 +65,18 @@
} }
} }
], ],
"reply_schema": {
"oneOf": [
{
"type": "string",
"description": "The element being popped from source and pushed to destination."
},
{
"type": "null",
"description": "Timeout is reached."
}
]
},
"arguments": [ "arguments": [
{ {
"name": "source", "name": "source",
......
...@@ -35,6 +35,46 @@ ...@@ -35,6 +35,46 @@
} }
} }
], ],
"reply_schema": {
"oneOf": [
{
"description": "Timeout reached and no elements were popped.",
"type": "null"
},
{
"description": "The keyname and the popped members.",
"type": "array",
"minItems": 2,
"maxItems": 2,
"items": [
{
"description": "Keyname",
"type": "string"
},
{
"description": "Popped members and their scores.",
"type": "array",
"uniqueItems": true,
"items": {
"type": "array",
"minItems": 2,
"maxItems": 2,
"items": [
{
"description": "Member",
"type": "string"
},
{
"description": "Score",
"type": "number"
}
]
}
}
]
}
]
},
"arguments": [ "arguments": [
{ {
"name": "timeout", "name": "timeout",
......
...@@ -42,6 +42,34 @@ ...@@ -42,6 +42,34 @@
} }
} }
], ],
"reply_schema": {
"oneOf": [
{
"description": "Timeout reached and no elements were popped.",
"type": "null"
},
{
"description": "The keyname, popped member, and its score.",
"type": "array",
"minItems": 3,
"maxItems": 3,
"items": [
{
"description": "Keyname",
"type": "string"
},
{
"description": "Member",
"type": "string"
},
{
"description": "Score",
"type": "number"
}
]
}
]
},
"arguments": [ "arguments": [
{ {
"name": "key", "name": "key",
......
...@@ -42,6 +42,34 @@ ...@@ -42,6 +42,34 @@
} }
} }
], ],
"reply_schema": {
"oneOf": [
{
"description": "Timeout reached and no elements were popped.",
"type": "null"
},
{
"description": "The keyname, popped member, and its score.",
"type": "array",
"minItems": 3,
"maxItems": 3,
"items": [
{
"description": "Keyname",
"type": "string"
},
{
"description": "Member",
"type": "string"
},
{
"description": "Score",
"type": "number"
}
]
}
]
},
"arguments": [ "arguments": [
{ {
"name": "key", "name": "key",
......
...@@ -16,6 +16,9 @@ ...@@ -16,6 +16,9 @@
"acl_categories": [ "acl_categories": [
"CONNECTION" "CONNECTION"
], ],
"reply_schema": {
"const": "OK"
},
"arguments": [ "arguments": [
{ {
"name": "mode", "name": "mode",
......
...@@ -15,6 +15,18 @@ ...@@ -15,6 +15,18 @@
], ],
"acl_categories": [ "acl_categories": [
"CONNECTION" "CONNECTION"
] ],
"reply_schema": {
"oneOf": [
{
"type": "string",
"description": "The connection name of the current connection"
},
{
"type": "null",
"description": "Connection name was not set"
}
]
}
} }
} }
...@@ -15,6 +15,23 @@ ...@@ -15,6 +15,23 @@
], ],
"acl_categories": [ "acl_categories": [
"CONNECTION" "CONNECTION"
] ],
"reply_schema": {
"oneOf": [
{
"const": 0,
"description": "Not redirecting notifications to any client."
},
{
"const": -1,
"description": "Client tracking is not enabled."
},
{
"type": "integer",
"description": "ID of the client we are redirecting the notifications to.",
"minimum": 1
}
]
}
} }
} }
...@@ -14,6 +14,13 @@ ...@@ -14,6 +14,13 @@
], ],
"acl_categories": [ "acl_categories": [
"CONNECTION" "CONNECTION"
] ],
"reply_schema": {
"type": "array",
"description": "Helpful text about subcommands.",
"items": {
"type": "string"
}
}
} }
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment