mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-09-08 22:10:50 +00:00
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:
57
tap/extensions/redis/helpers.go
Normal file
57
tap/extensions/redis/helpers.go
Normal 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
|
||||
}
|
Reference in New Issue
Block a user