mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-09-29 06:17:40 +00:00
* Fix the OOMKilled error by calling `debug.FreeOSMemory` periodically * Remove `MAX_NUMBER_OF_GOROUTINES` environment variable * Change the line * Increase the default value of `TCP_STREAM_CHANNEL_TIMEOUT_MS` to `10000` * Write the client and integrate to the new real-time database * Refactor the WebSocket implementaiton for `/ws` * Adapt the UI to the new filtering system * Fix the rest of the issues in the UI * Increase the buffer of the scanner * Implement accessing single records * Increase the buffer of another scanner * Populate `Request` and `Response` fields of `MizuEntry` * Add syntax highlighting for the query * Add database to `Dockerfile` * Fix some issues * Update the `realtime_dbms` Git module commit hash * Upgrade Gin version and print the query string * Revert "Upgrade Gin version and print the query string" This reverts commitaa09f904ee
. * Use WebSocket's itself to query instead of the query string * Fix some errors related to conversion to HAR * Fix the issues caused by the latest merge * Fix the build error * Fix PR validation GitHub workflow * Replace the git submodule with latest Basenine version `0.1.0` Remove `realtime_client.go` and use the official client library `github.com/up9inc/basenine/client/go` instead. * Move Basenine host and port constants to `shared` module * Reliably execute and wait for Basenine to become available * Upgrade Basenine version * Properly close WebSocket and data channel * Fix the issues caused by the recent merge commit * Clean up the TypeScript code * Update `.gitignore` * Limit the database size * Add `Macros` method signature to `Dissector` interface and set the macros provided by the protocol extensions * Run `go mod tidy` on `agent` * Upgrade `github.com/up9inc/basenine/client/go` version * Implement a mechanism to update the query using click events in the UI and use it for protocol macros * Update the query on click to timestamps * Fix some issues in the WebSocket and channel handling * Update the query on clicks to status code * Update the query on clicks to method, path and service * Update the query on clicks to is outgoing, source and destination ports * Add an API endpoint to validate the query against syntax errors * Move the query background color state into `TrafficPage` * Fix the logic in `setQuery` * Display a toast message in case of a syntax error in the query * Remove a call to `fmt.Printf` * Upgrade Basenine version to `0.1.3` * Fix an issue related to getting `MAX_ENTRIES_DB_BYTES` environment variable * Have the `path` key in request details, in HTTP * Rearrange the HTTP headers for the querying * Do the same thing for `cookies` and `queryString` * Update the query on click to table elements Add the selectors for `TABLE` type representations in HTTP extension. * Update the query on click to `bodySize` and `elapsedTime` in `EntryTitle` * Add the selectors for `TABLE` type representations in AMQP extension * Add the selectors for `TABLE` type representations in Kafka extension * Add the selectors for `TABLE` type representations in Redis extension * Define a struct in `tap/api.go` for the section representation data * Add the selectors for `BODY` type representations * Add `request.path` to the HTTP request details * Change the summary string's field name from `path` to `summary` * Introduce `queryable` CSS class for queryable UI elements and underline them on hover * Instead of `N requests` at the bottom, make it `Displaying N results (queried X/Y)` and live update the values Upgrade Basenine version to `0.2.0`. * Verify the sha256sum of Basenine executable inside `Dockerfile` * Pass the start time to web UI through WebSocket and always show the `EntriesList` footer * Pipe the `stderr` of Basenine as well * Fix the layout issues related to `CodeEditor` in the UI * Use the correct `shasum` command in `Dockerfile` * Upgrade Basenine version to `0.2.1` * Limit the height of `CodeEditor` container * Remove `Paused` enum `ConnectionStatus` in UI * Fix the issue caused by the recent merge * Add the filtering guide (cheatsheet) * Update open cheatsheet button's title * Update cheatsheet content * Remove the old SQLite code, adapt the `--analyze` related code to Basenine * Change the method signature of `NewEntry` * Change the method signature of `Represent` * Introduce `HTTPPair` field in `MizuEntry` specific to HTTP * Remove `Entry`, `EntryId` and `EstimatedSizeBytes` fields from `MizuEntry` Also remove the `getEstimatedEntrySizeBytes` method. * Remove `gorm.io/gorm` dependency * Remove unused `sensitiveDataFiltering` folder * Increase the left margin of open cheatsheet button * Add `overflow: auto` to the cheatsheet `Modal` * Fix `GetEntry` method * Fix the macro for gRPC * Fix an interface conversion in case of AMQP * Fix two more interface conversion errors in AMQP * Make the `syncEntriesImpl` method blocking * Fix a grammar mistake in the cheatsheet * Adapt to the changes in the recent merge commit * Improve the cheatsheet text * Always display the timestamp in `en-US` * Upgrade Basenine version to `0.2.2` * Fix the order of closing Basenine connections and channels * Don't close the Basenine channels at all * Upgrade Basenine version to `0.2.3` * Set the initial filter to `rlimit(100)` * Make Basenine persistent * Upgrade Basenine version to `0.2.4` * Update `debug.Dockerfile` * Fix a failing test * Upgrade Basenine version to `0.2.5` * Revert "Do not show play icon when disconnected (#428)" This reverts commit8af2e562f8
. * Upgrade Basenine version to `0.2.6` * Make all non-informative things informative * Make `100` a constant * Use `===` in JavaScript no matter what * Remove a forgotten `console.log` * Add a comment and update the `query` in `syncEntriesImpl` * Don't call `panic` in `GetEntry` * Replace `panic` calls in `startBasenineServer` with `logger.Log.Panicf` * Remove unnecessary `\n` characters in the logs
730 lines
18 KiB
Go
730 lines
18 KiB
Go
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
"strconv"
|
|
|
|
"github.com/up9inc/mizu/tap/api"
|
|
)
|
|
|
|
type KafkaPayload struct {
|
|
Data interface{}
|
|
}
|
|
|
|
type KafkaPayloader interface {
|
|
MarshalJSON() ([]byte, error)
|
|
}
|
|
|
|
func (h KafkaPayload) MarshalJSON() ([]byte, error) {
|
|
return json.Marshal(h.Data)
|
|
}
|
|
|
|
type KafkaWrapper struct {
|
|
Method string `json:"method"`
|
|
Url string `json:"url"`
|
|
Details interface{} `json:"details"`
|
|
}
|
|
|
|
func representRequestHeader(data map[string]interface{}, rep []interface{}) []interface{} {
|
|
requestHeader, _ := json.Marshal([]api.TableData{
|
|
{
|
|
Name: "ApiKey",
|
|
Value: apiNames[int(data["apiKey"].(float64))],
|
|
Selector: `request.apiKey`,
|
|
},
|
|
{
|
|
Name: "ApiVersion",
|
|
Value: fmt.Sprintf("%d", int(data["apiVersion"].(float64))),
|
|
Selector: `request.apiVersion`,
|
|
},
|
|
{
|
|
Name: "Client ID",
|
|
Value: data["clientID"].(string),
|
|
Selector: `request.clientID`,
|
|
},
|
|
{
|
|
Name: "Correlation ID",
|
|
Value: fmt.Sprintf("%d", int(data["correlationID"].(float64))),
|
|
Selector: `request.correlationID`,
|
|
},
|
|
{
|
|
Name: "Size",
|
|
Value: fmt.Sprintf("%d", int(data["size"].(float64))),
|
|
Selector: `request.size`,
|
|
},
|
|
})
|
|
rep = append(rep, api.SectionData{
|
|
Type: api.TABLE,
|
|
Title: "Request Header",
|
|
Data: string(requestHeader),
|
|
})
|
|
|
|
return rep
|
|
}
|
|
|
|
func representResponseHeader(data map[string]interface{}, rep []interface{}) []interface{} {
|
|
requestHeader, _ := json.Marshal([]api.TableData{
|
|
{
|
|
Name: "Correlation ID",
|
|
Value: fmt.Sprintf("%d", int(data["correlationID"].(float64))),
|
|
Selector: `response.correlationID`,
|
|
},
|
|
})
|
|
rep = append(rep, api.SectionData{
|
|
Type: api.TABLE,
|
|
Title: "Response Header",
|
|
Data: string(requestHeader),
|
|
})
|
|
|
|
return rep
|
|
}
|
|
|
|
func representMetadataRequest(data map[string]interface{}) []interface{} {
|
|
rep := make([]interface{}, 0)
|
|
|
|
rep = representRequestHeader(data, rep)
|
|
|
|
payload := data["payload"].(map[string]interface{})
|
|
topics := ""
|
|
allowAutoTopicCreation := ""
|
|
includeClusterAuthorizedOperations := ""
|
|
includeTopicAuthorizedOperations := ""
|
|
if payload["topics"] != nil {
|
|
x, _ := json.Marshal(payload["topics"].([]interface{}))
|
|
topics = string(x)
|
|
}
|
|
if payload["allowAutoTopicCreation"] != nil {
|
|
allowAutoTopicCreation = strconv.FormatBool(payload["allowAutoTopicCreation"].(bool))
|
|
}
|
|
if payload["includeClusterAuthorizedOperations"] != nil {
|
|
includeClusterAuthorizedOperations = strconv.FormatBool(payload["includeClusterAuthorizedOperations"].(bool))
|
|
}
|
|
if payload["includeTopicAuthorizedOperations"] != nil {
|
|
includeTopicAuthorizedOperations = strconv.FormatBool(payload["includeTopicAuthorizedOperations"].(bool))
|
|
}
|
|
repPayload, _ := json.Marshal([]api.TableData{
|
|
{
|
|
Name: "Topics",
|
|
Value: topics,
|
|
Selector: `request.payload.topics`,
|
|
},
|
|
{
|
|
Name: "Allow Auto Topic Creation",
|
|
Value: allowAutoTopicCreation,
|
|
Selector: `request.payload.allowAutoTopicCreation`,
|
|
},
|
|
{
|
|
Name: "Include Cluster Authorized Operations",
|
|
Value: includeClusterAuthorizedOperations,
|
|
Selector: `request.payload.includeClusterAuthorizedOperations`,
|
|
},
|
|
{
|
|
Name: "Include Topic Authorized Operations",
|
|
Value: includeTopicAuthorizedOperations,
|
|
Selector: `request.payload.includeTopicAuthorizedOperations`,
|
|
},
|
|
})
|
|
rep = append(rep, api.SectionData{
|
|
Type: api.TABLE,
|
|
Title: "Payload",
|
|
Data: string(repPayload),
|
|
})
|
|
|
|
return rep
|
|
}
|
|
|
|
func representMetadataResponse(data map[string]interface{}) []interface{} {
|
|
rep := make([]interface{}, 0)
|
|
|
|
rep = representResponseHeader(data, rep)
|
|
|
|
payload := data["payload"].(map[string]interface{})
|
|
topics := ""
|
|
if payload["topics"] != nil {
|
|
_topics, _ := json.Marshal(payload["topics"].([]interface{}))
|
|
topics = string(_topics)
|
|
}
|
|
brokers := ""
|
|
if payload["brokers"] != nil {
|
|
_brokers, _ := json.Marshal(payload["brokers"].([]interface{}))
|
|
brokers = string(_brokers)
|
|
}
|
|
controllerID := ""
|
|
clusterID := ""
|
|
throttleTimeMs := ""
|
|
clusterAuthorizedOperations := ""
|
|
if payload["controllerID"] != nil {
|
|
controllerID = fmt.Sprintf("%d", int(payload["controllerID"].(float64)))
|
|
}
|
|
if payload["clusterID"] != nil {
|
|
clusterID = payload["clusterID"].(string)
|
|
}
|
|
if payload["throttleTimeMs"] != nil {
|
|
throttleTimeMs = fmt.Sprintf("%d", int(payload["throttleTimeMs"].(float64)))
|
|
}
|
|
if payload["clusterAuthorizedOperations"] != nil {
|
|
clusterAuthorizedOperations = fmt.Sprintf("%d", int(payload["clusterAuthorizedOperations"].(float64)))
|
|
}
|
|
repPayload, _ := json.Marshal([]api.TableData{
|
|
{
|
|
Name: "Throttle Time (ms)",
|
|
Value: throttleTimeMs,
|
|
Selector: `response.payload.throttleTimeMs`,
|
|
},
|
|
{
|
|
Name: "Brokers",
|
|
Value: brokers,
|
|
Selector: `response.payload.brokers`,
|
|
},
|
|
{
|
|
Name: "Cluster ID",
|
|
Value: clusterID,
|
|
Selector: `response.payload.clusterID`,
|
|
},
|
|
{
|
|
Name: "Controller ID",
|
|
Value: controllerID,
|
|
Selector: `response.payload.controllerID`,
|
|
},
|
|
{
|
|
Name: "Topics",
|
|
Value: topics,
|
|
Selector: `response.payload.topics`,
|
|
},
|
|
{
|
|
Name: "Cluster Authorized Operations",
|
|
Value: clusterAuthorizedOperations,
|
|
Selector: `response.payload.clusterAuthorizedOperations`,
|
|
},
|
|
})
|
|
rep = append(rep, api.SectionData{
|
|
Type: api.TABLE,
|
|
Title: "Payload",
|
|
Data: string(repPayload),
|
|
})
|
|
|
|
return rep
|
|
}
|
|
|
|
func representApiVersionsRequest(data map[string]interface{}) []interface{} {
|
|
rep := make([]interface{}, 0)
|
|
|
|
rep = representRequestHeader(data, rep)
|
|
|
|
payload := data["payload"].(map[string]interface{})
|
|
clientSoftwareName := ""
|
|
clientSoftwareVersion := ""
|
|
if payload["clientSoftwareName"] != nil {
|
|
clientSoftwareName = payload["clientSoftwareName"].(string)
|
|
}
|
|
if payload["clientSoftwareVersion"] != nil {
|
|
clientSoftwareVersion = payload["clientSoftwareVersion"].(string)
|
|
}
|
|
repPayload, _ := json.Marshal([]api.TableData{
|
|
{
|
|
Name: "Client Software Name",
|
|
Value: clientSoftwareName,
|
|
Selector: `request.payload.clientSoftwareName`,
|
|
},
|
|
{
|
|
Name: "Client Software Version",
|
|
Value: clientSoftwareVersion,
|
|
Selector: `request.payload.clientSoftwareVersion`,
|
|
},
|
|
})
|
|
rep = append(rep, api.SectionData{
|
|
Type: api.TABLE,
|
|
Title: "Payload",
|
|
Data: string(repPayload),
|
|
})
|
|
|
|
return rep
|
|
}
|
|
|
|
func representApiVersionsResponse(data map[string]interface{}) []interface{} {
|
|
rep := make([]interface{}, 0)
|
|
|
|
rep = representResponseHeader(data, rep)
|
|
|
|
payload := data["payload"].(map[string]interface{})
|
|
apiKeys := ""
|
|
if payload["apiKeys"] != nil {
|
|
x, _ := json.Marshal(payload["apiKeys"].([]interface{}))
|
|
apiKeys = string(x)
|
|
}
|
|
throttleTimeMs := ""
|
|
if payload["throttleTimeMs"] != nil {
|
|
throttleTimeMs = fmt.Sprintf("%d", int(payload["throttleTimeMs"].(float64)))
|
|
}
|
|
repPayload, _ := json.Marshal([]api.TableData{
|
|
{
|
|
Name: "Error Code",
|
|
Value: fmt.Sprintf("%d", int(payload["errorCode"].(float64))),
|
|
Selector: `response.payload.errorCode`,
|
|
},
|
|
{
|
|
Name: "ApiKeys",
|
|
Value: apiKeys,
|
|
Selector: `response.payload.apiKeys`,
|
|
},
|
|
{
|
|
Name: "Throttle Time (ms)",
|
|
Value: throttleTimeMs,
|
|
Selector: `response.payload.throttleTimeMs`,
|
|
},
|
|
})
|
|
rep = append(rep, api.SectionData{
|
|
Type: api.TABLE,
|
|
Title: "Payload",
|
|
Data: string(repPayload),
|
|
})
|
|
|
|
return rep
|
|
}
|
|
|
|
func representProduceRequest(data map[string]interface{}) []interface{} {
|
|
rep := make([]interface{}, 0)
|
|
|
|
rep = representRequestHeader(data, rep)
|
|
|
|
payload := data["payload"].(map[string]interface{})
|
|
topicData := ""
|
|
_topicData := payload["topicData"]
|
|
if _topicData != nil {
|
|
x, _ := json.Marshal(_topicData.([]interface{}))
|
|
topicData = string(x)
|
|
}
|
|
transactionalID := ""
|
|
if payload["transactionalID"] != nil {
|
|
transactionalID = payload["transactionalID"].(string)
|
|
}
|
|
repPayload, _ := json.Marshal([]api.TableData{
|
|
{
|
|
Name: "Transactional ID",
|
|
Value: transactionalID,
|
|
Selector: `request.payload.transactionalID`,
|
|
},
|
|
{
|
|
Name: "Required Acknowledgements",
|
|
Value: fmt.Sprintf("%d", int(payload["requiredAcks"].(float64))),
|
|
Selector: `request.payload.requiredAcks`,
|
|
},
|
|
{
|
|
Name: "Timeout",
|
|
Value: fmt.Sprintf("%d", int(payload["timeout"].(float64))),
|
|
Selector: `request.payload.timeout`,
|
|
},
|
|
{
|
|
Name: "Topic Data",
|
|
Value: topicData,
|
|
Selector: `request.payload.topicData`,
|
|
},
|
|
})
|
|
rep = append(rep, api.SectionData{
|
|
Type: api.TABLE,
|
|
Title: "Payload",
|
|
Data: string(repPayload),
|
|
})
|
|
|
|
return rep
|
|
}
|
|
|
|
func representProduceResponse(data map[string]interface{}) []interface{} {
|
|
rep := make([]interface{}, 0)
|
|
|
|
rep = representResponseHeader(data, rep)
|
|
|
|
payload := data["payload"].(map[string]interface{})
|
|
responses := ""
|
|
if payload["responses"] != nil {
|
|
_responses, _ := json.Marshal(payload["responses"].([]interface{}))
|
|
responses = string(_responses)
|
|
}
|
|
throttleTimeMs := ""
|
|
if payload["throttleTimeMs"] != nil {
|
|
throttleTimeMs = fmt.Sprintf("%d", int(payload["throttleTimeMs"].(float64)))
|
|
}
|
|
repPayload, _ := json.Marshal([]api.TableData{
|
|
{
|
|
Name: "Responses",
|
|
Value: string(responses),
|
|
Selector: `response.payload.responses`,
|
|
},
|
|
{
|
|
Name: "Throttle Time (ms)",
|
|
Value: throttleTimeMs,
|
|
Selector: `response.payload.throttleTimeMs`,
|
|
},
|
|
})
|
|
rep = append(rep, api.SectionData{
|
|
Type: api.TABLE,
|
|
Title: "Payload",
|
|
Data: string(repPayload),
|
|
})
|
|
|
|
return rep
|
|
}
|
|
|
|
func representFetchRequest(data map[string]interface{}) []interface{} {
|
|
rep := make([]interface{}, 0)
|
|
|
|
rep = representRequestHeader(data, rep)
|
|
|
|
payload := data["payload"].(map[string]interface{})
|
|
topics := ""
|
|
if payload["topics"] != nil {
|
|
_topics, _ := json.Marshal(payload["topics"].([]interface{}))
|
|
topics = string(_topics)
|
|
}
|
|
replicaId := ""
|
|
if payload["replicaId"] != nil {
|
|
replicaId = fmt.Sprintf("%d", int(payload["replicaId"].(float64)))
|
|
}
|
|
maxBytes := ""
|
|
if payload["maxBytes"] != nil {
|
|
maxBytes = fmt.Sprintf("%d", int(payload["maxBytes"].(float64)))
|
|
}
|
|
isolationLevel := ""
|
|
if payload["isolationLevel"] != nil {
|
|
isolationLevel = fmt.Sprintf("%d", int(payload["isolationLevel"].(float64)))
|
|
}
|
|
sessionId := ""
|
|
if payload["sessionId"] != nil {
|
|
sessionId = fmt.Sprintf("%d", int(payload["sessionId"].(float64)))
|
|
}
|
|
sessionEpoch := ""
|
|
if payload["sessionEpoch"] != nil {
|
|
sessionEpoch = fmt.Sprintf("%d", int(payload["sessionEpoch"].(float64)))
|
|
}
|
|
forgottenTopicsData := ""
|
|
if payload["forgottenTopicsData"] != nil {
|
|
x, _ := json.Marshal(payload["forgottenTopicsData"].(map[string]interface{}))
|
|
forgottenTopicsData = string(x)
|
|
}
|
|
rackId := ""
|
|
if payload["rackId"] != nil {
|
|
rackId = payload["rackId"].(string)
|
|
}
|
|
repPayload, _ := json.Marshal([]api.TableData{
|
|
{
|
|
Name: "Replica ID",
|
|
Value: replicaId,
|
|
Selector: `request.payload.replicaId`,
|
|
},
|
|
{
|
|
Name: "Maximum Wait (ms)",
|
|
Value: fmt.Sprintf("%d", int(payload["maxWaitMs"].(float64))),
|
|
Selector: `request.payload.maxWaitMs`,
|
|
},
|
|
{
|
|
Name: "Minimum Bytes",
|
|
Value: fmt.Sprintf("%d", int(payload["minBytes"].(float64))),
|
|
Selector: `request.payload.minBytes`,
|
|
},
|
|
{
|
|
Name: "Maximum Bytes",
|
|
Value: maxBytes,
|
|
Selector: `request.payload.maxBytes`,
|
|
},
|
|
{
|
|
Name: "Isolation Level",
|
|
Value: isolationLevel,
|
|
Selector: `request.payload.isolationLevel`,
|
|
},
|
|
{
|
|
Name: "Session ID",
|
|
Value: sessionId,
|
|
Selector: `request.payload.sessionId`,
|
|
},
|
|
{
|
|
Name: "Session Epoch",
|
|
Value: sessionEpoch,
|
|
Selector: `request.payload.sessionEpoch`,
|
|
},
|
|
{
|
|
Name: "Topics",
|
|
Value: topics,
|
|
Selector: `request.payload.topics`,
|
|
},
|
|
{
|
|
Name: "Forgotten Topics Data",
|
|
Value: forgottenTopicsData,
|
|
Selector: `request.payload.forgottenTopicsData`,
|
|
},
|
|
{
|
|
Name: "Rack ID",
|
|
Value: rackId,
|
|
Selector: `request.payload.rackId`,
|
|
},
|
|
})
|
|
rep = append(rep, api.SectionData{
|
|
Type: api.TABLE,
|
|
Title: "Payload",
|
|
Data: string(repPayload),
|
|
})
|
|
|
|
return rep
|
|
}
|
|
|
|
func representFetchResponse(data map[string]interface{}) []interface{} {
|
|
rep := make([]interface{}, 0)
|
|
|
|
rep = representResponseHeader(data, rep)
|
|
|
|
payload := data["payload"].(map[string]interface{})
|
|
responses := ""
|
|
if payload["responses"] != nil {
|
|
_responses, _ := json.Marshal(payload["responses"].([]interface{}))
|
|
responses = string(_responses)
|
|
}
|
|
throttleTimeMs := ""
|
|
if payload["throttleTimeMs"] != nil {
|
|
throttleTimeMs = fmt.Sprintf("%d", int(payload["throttleTimeMs"].(float64)))
|
|
}
|
|
errorCode := ""
|
|
if payload["errorCode"] != nil {
|
|
errorCode = fmt.Sprintf("%d", int(payload["errorCode"].(float64)))
|
|
}
|
|
sessionId := ""
|
|
if payload["sessionId"] != nil {
|
|
sessionId = fmt.Sprintf("%d", int(payload["sessionId"].(float64)))
|
|
}
|
|
repPayload, _ := json.Marshal([]api.TableData{
|
|
{
|
|
Name: "Throttle Time (ms)",
|
|
Value: throttleTimeMs,
|
|
Selector: `response.payload.throttleTimeMs`,
|
|
},
|
|
{
|
|
Name: "Error Code",
|
|
Value: errorCode,
|
|
Selector: `response.payload.errorCode`,
|
|
},
|
|
{
|
|
Name: "Session ID",
|
|
Value: sessionId,
|
|
Selector: `response.payload.sessionId`,
|
|
},
|
|
{
|
|
Name: "Responses",
|
|
Value: responses,
|
|
Selector: `response.payload.responses`,
|
|
},
|
|
})
|
|
rep = append(rep, api.SectionData{
|
|
Type: api.TABLE,
|
|
Title: "Payload",
|
|
Data: string(repPayload),
|
|
})
|
|
|
|
return rep
|
|
}
|
|
|
|
func representListOffsetsRequest(data map[string]interface{}) []interface{} {
|
|
rep := make([]interface{}, 0)
|
|
|
|
rep = representRequestHeader(data, rep)
|
|
|
|
payload := data["payload"].(map[string]interface{})
|
|
topics := ""
|
|
if payload["topics"] != nil {
|
|
_topics, _ := json.Marshal(payload["topics"].([]interface{}))
|
|
topics = string(_topics)
|
|
}
|
|
repPayload, _ := json.Marshal([]api.TableData{
|
|
{
|
|
Name: "Replica ID",
|
|
Value: fmt.Sprintf("%d", int(payload["replicaId"].(float64))),
|
|
Selector: `request.payload.replicaId`,
|
|
},
|
|
{
|
|
Name: "Topics",
|
|
Value: topics,
|
|
Selector: `request.payload.topics`,
|
|
},
|
|
})
|
|
rep = append(rep, api.SectionData{
|
|
Type: api.TABLE,
|
|
Title: "Payload",
|
|
Data: string(repPayload),
|
|
})
|
|
|
|
return rep
|
|
}
|
|
|
|
func representListOffsetsResponse(data map[string]interface{}) []interface{} {
|
|
rep := make([]interface{}, 0)
|
|
|
|
rep = representResponseHeader(data, rep)
|
|
|
|
payload := data["payload"].(map[string]interface{})
|
|
topics, _ := json.Marshal(payload["topics"].([]interface{}))
|
|
throttleTimeMs := ""
|
|
if payload["throttleTimeMs"] != nil {
|
|
throttleTimeMs = fmt.Sprintf("%d", int(payload["throttleTimeMs"].(float64)))
|
|
}
|
|
repPayload, _ := json.Marshal([]api.TableData{
|
|
{
|
|
Name: "Throttle Time (ms)",
|
|
Value: throttleTimeMs,
|
|
Selector: `response.payload.throttleTimeMs`,
|
|
},
|
|
{
|
|
Name: "Topics",
|
|
Value: string(topics),
|
|
Selector: `response.payload.topics`,
|
|
},
|
|
})
|
|
rep = append(rep, api.SectionData{
|
|
Type: api.TABLE,
|
|
Title: "Payload",
|
|
Data: string(repPayload),
|
|
})
|
|
|
|
return rep
|
|
}
|
|
|
|
func representCreateTopicsRequest(data map[string]interface{}) []interface{} {
|
|
rep := make([]interface{}, 0)
|
|
|
|
rep = representRequestHeader(data, rep)
|
|
|
|
payload := data["payload"].(map[string]interface{})
|
|
topics, _ := json.Marshal(payload["topics"].([]interface{}))
|
|
validateOnly := ""
|
|
if payload["validateOnly"] != nil {
|
|
validateOnly = strconv.FormatBool(payload["validateOnly"].(bool))
|
|
}
|
|
repPayload, _ := json.Marshal([]api.TableData{
|
|
{
|
|
Name: "Topics",
|
|
Value: string(topics),
|
|
Selector: `request.payload.topics`,
|
|
},
|
|
{
|
|
Name: "Timeout (ms)",
|
|
Value: fmt.Sprintf("%d", int(payload["timeoutMs"].(float64))),
|
|
Selector: `request.payload.timeoutMs`,
|
|
},
|
|
{
|
|
Name: "Validate Only",
|
|
Value: validateOnly,
|
|
Selector: `request.payload.validateOnly`,
|
|
},
|
|
})
|
|
rep = append(rep, api.SectionData{
|
|
Type: api.TABLE,
|
|
Title: "Payload",
|
|
Data: string(repPayload),
|
|
})
|
|
|
|
return rep
|
|
}
|
|
|
|
func representCreateTopicsResponse(data map[string]interface{}) []interface{} {
|
|
rep := make([]interface{}, 0)
|
|
|
|
rep = representResponseHeader(data, rep)
|
|
|
|
payload := data["payload"].(map[string]interface{})
|
|
topics, _ := json.Marshal(payload["topics"].([]interface{}))
|
|
throttleTimeMs := ""
|
|
if payload["throttleTimeMs"] != nil {
|
|
throttleTimeMs = fmt.Sprintf("%d", int(payload["throttleTimeMs"].(float64)))
|
|
}
|
|
repPayload, _ := json.Marshal([]api.TableData{
|
|
{
|
|
Name: "Throttle Time (ms)",
|
|
Value: throttleTimeMs,
|
|
Selector: `response.payload.throttleTimeMs`,
|
|
},
|
|
{
|
|
Name: "Topics",
|
|
Value: string(topics),
|
|
Selector: `response.payload.topics`,
|
|
},
|
|
})
|
|
rep = append(rep, api.SectionData{
|
|
Type: api.TABLE,
|
|
Title: "Payload",
|
|
Data: string(repPayload),
|
|
})
|
|
|
|
return rep
|
|
}
|
|
|
|
func representDeleteTopicsRequest(data map[string]interface{}) []interface{} {
|
|
rep := make([]interface{}, 0)
|
|
|
|
rep = representRequestHeader(data, rep)
|
|
|
|
payload := data["payload"].(map[string]interface{})
|
|
topics := ""
|
|
if payload["topics"] != nil {
|
|
x, _ := json.Marshal(payload["topics"].([]interface{}))
|
|
topics = string(x)
|
|
}
|
|
topicNames := ""
|
|
if payload["topicNames"] != nil {
|
|
x, _ := json.Marshal(payload["topicNames"].([]interface{}))
|
|
topicNames = string(x)
|
|
}
|
|
repPayload, _ := json.Marshal([]api.TableData{
|
|
{
|
|
Name: "TopicNames",
|
|
Value: string(topicNames),
|
|
Selector: `request.payload.topicNames`,
|
|
},
|
|
{
|
|
Name: "Topics",
|
|
Value: string(topics),
|
|
Selector: `request.payload.topics`,
|
|
},
|
|
{
|
|
Name: "Timeout (ms)",
|
|
Value: fmt.Sprintf("%d", int(payload["timeoutMs"].(float64))),
|
|
Selector: `request.payload.timeoutMs`,
|
|
},
|
|
})
|
|
rep = append(rep, api.SectionData{
|
|
Type: api.TABLE,
|
|
Title: "Payload",
|
|
Data: string(repPayload),
|
|
})
|
|
|
|
return rep
|
|
}
|
|
|
|
func representDeleteTopicsResponse(data map[string]interface{}) []interface{} {
|
|
rep := make([]interface{}, 0)
|
|
|
|
rep = representResponseHeader(data, rep)
|
|
|
|
payload := data["payload"].(map[string]interface{})
|
|
responses, _ := json.Marshal(payload["responses"].([]interface{}))
|
|
throttleTimeMs := ""
|
|
if payload["throttleTimeMs"] != nil {
|
|
throttleTimeMs = fmt.Sprintf("%d", int(payload["throttleTimeMs"].(float64)))
|
|
}
|
|
repPayload, _ := json.Marshal([]api.TableData{
|
|
{
|
|
Name: "Throttle Time (ms)",
|
|
Value: throttleTimeMs,
|
|
Selector: `response.payload.throttleTimeMs`,
|
|
},
|
|
{
|
|
Name: "Responses",
|
|
Value: string(responses),
|
|
Selector: `response.payload.responses`,
|
|
},
|
|
})
|
|
rep = append(rep, api.SectionData{
|
|
Type: api.TABLE,
|
|
Title: "Payload",
|
|
Data: string(repPayload),
|
|
})
|
|
|
|
return rep
|
|
}
|