Skip to content

Commit

Permalink
Merge pull request #55 from tzachshabtay/schema_id
Browse files Browse the repository at this point in the history
add schema id to subject versions view
  • Loading branch information
tzachshabtay authored Apr 8, 2021
2 parents 4f31268 + cce1bcb commit bf86ffb
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 17 deletions.
17 changes: 9 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"@material-ui/core": "^4.11.3",
"@material-ui/icons": "^4.9.1",
"@material-ui/lab": "^4.0.0-alpha.56",
"@ovotech/avro-kafkajs": "^0.3.0",
"@ovotech/avro-kafkajs": "^0.6.3",
"@types/long": "^4.0.1",
"ag-grid-community": "^23.2.0",
"ag-grid-react": "^23.2.0",
Expand Down
9 changes: 6 additions & 3 deletions src/client/schema-registry/versions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ interface RecordType {

type Version = {
version: number,
schema?: GetSchemaResult,
schema?: Schema,
schemaID?: number,
[key: string]: any,
}

Expand Down Expand Up @@ -92,8 +93,9 @@ export class Versions extends React.Component<RouteComponentProps<{ subject: str
this.setState({loading: false, error: data.error, errorPrefix: `Failed to fetch schema for version ${version.version}. Error: `})
return
}
version.schema = data
this.addToRow(version, data as RecordType, customCols, "")
version.schema = data.schema
version.schemaID = data.id
this.addToRow(version, data.schema as RecordType, customCols, "")
if (this.gridApi) {
this.gridApi.refreshCells()
}
Expand Down Expand Up @@ -134,6 +136,7 @@ export class Versions extends React.Component<RouteComponentProps<{ subject: str

getColumnDefs() {
const cols = [
{ headerName: "Schema ID", field: "schemaID", filter: "agNumberColumnFilter" },
{ headerName: "Version", field: "version", filter: "agNumberColumnFilter" },
{ headerName: "Type", field: "schema.type" },
{ headerName: "Name", field: "schema.name" },
Expand Down
10 changes: 6 additions & 4 deletions src/server/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import express from "express";
import http from "http";
import path from "path";
import { Kafka, ResourceTypes, DescribeConfigResponse, Consumer, Admin, GroupDescriptions } from "kafkajs";
import { SchemaRegistry } from '@ovotech/avro-kafkajs';
import { Type } from "avsc";
import { SchemaRegistry, SchemaVersion } from '@ovotech/avro-kafkajs';
import { Schema, Type } from "avsc";
import { v4 as uuidv4 } from 'uuid';
import { KAFKA_URLS, SCHEMA_REGISTRY_URL, KAFKA_CONNECT_URL } from "./config";
import { GetTopicsResult, GetTopicResult, TopicsOffsets, ConsumerOffsets, TopicConsumerGroups, TopicOffsets, GetClusterResult, GetTopicOffsetsByTimestapResult, TopicMessage, TopicMessages, GetTopicMessagesResult, GetSubjectsResult, GetSubjectVersionsResult, GetSchemaResult, GetTopicConsumerGroupsResult, GetTopicOffsetsResult, GetConnectorsResult, GetConnectorStatusResult, GetConnectorConfigResult, GetConnectorTasksResult, GetConnectorTaskStatusResult } from "../shared/api";
Expand Down Expand Up @@ -264,8 +264,10 @@ app.get("/api/schema-registry/versions/:subject", async (req, res) => {

app.get("/api/schema-registry/schema/:subject/:version", async (req, res) => {
try {
const schema: GetSchemaResult = await schemaRegistry.getSubjectVersionSchema(req.params.subject, parseInt(req.params.version))
res.status(200).json(schema)
const schemaVersion: SchemaVersion = await schemaRegistry.getSubjectVersion(req.params.subject, parseInt(req.params.version))
const schema: Schema = JSON.parse(schemaVersion.schema)
const out: GetSchemaResult = { schema, id: schemaVersion.id }
res.status(200).json(out)
}
catch (error) {
res.status(500).json({ error: error.toString() })
Expand Down
2 changes: 1 addition & 1 deletion src/shared/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export type GetTopicMessagesResult = MaybeError & TopicMessages

export type GetSubjectsResult = MaybeError & string[]
export type GetSubjectVersionsResult = MaybeError & number[]
export type GetSchemaResult = MaybeError & Schema
export type GetSchemaResult = MaybeError & { schema: Schema, id: number }

export type ConnectorState = `RUNNING` | `FAILED` | `PAUSED`
export type ConnectorConfig = { [key: string]: string }
Expand Down

0 comments on commit bf86ffb

Please sign in to comment.