Add Redis Serialization Protocol support (#290)

* Bring in the files

* Add request-response pair matcher for Redis

* Implement the `Represent` method

* Update `representGeneric` method signature

* Don't export `IntToByteArr`

* Remove unused `newRedisInputStream` method

* Return the errors as string

* Adapt to the latest change in the `develop`
This commit is contained in:
M. Mert Yıldıran
2021-09-23 17:09:00 +03:00
committed by GitHub
parent 8ba96acf05
commit 7b333556d0
8 changed files with 1155 additions and 0 deletions

View File

@@ -0,0 +1,57 @@
package main
import (
"encoding/json"
"github.com/up9inc/mizu/tap/api"
)
type RedisPayload struct {
Data interface{}
}
type RedisPayloader interface {
MarshalJSON() ([]byte, error)
}
func (h RedisPayload) MarshalJSON() ([]byte, error) {
return json.Marshal(h.Data)
}
type RedisWrapper struct {
Method string `json:"method"`
Url string `json:"url"`
Details interface{} `json:"details"`
}
func representGeneric(generic map[string]string) (representation []interface{}) {
details, _ := json.Marshal([]map[string]string{
{
"name": "Type",
"value": generic["type"],
},
{
"name": "Command",
"value": generic["command"],
},
{
"name": "Key",
"value": generic["key"],
},
{
"name": "Value",
"value": generic["value"],
},
{
"name": "Keyword",
"value": generic["keyword"],
},
})
representation = append(representation, map[string]string{
"type": api.TABLE,
"title": "Details",
"data": string(details),
})
return
}