wolfstudy commented on a change in pull request #3904: [go schema] support go schema for pulsar-client-go URL: https://github.com/apache/pulsar/pull/3904#discussion_r273318725
########## File path: pulsar-client-go/pulsar/schema_test.go ########## @@ -0,0 +1,502 @@ +// +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// + +package pulsar + +import ( + "context" + "testing" + + log "github.com/apache/pulsar/pulsar-client-go/logutil" + "github.com/apache/pulsar/pulsar-client-go/pulsar/pb" + "github.com/stretchr/testify/assert" +) + +type testSchema struct { + ID int `json:"id"` + Name string `json:"name"` +} + +func TestJsonSchema(t *testing.T) { + // create client + lookupUrl := "pulsar://localhost:6650" + client, err := NewClient(ClientOptions{ + URL: lookupUrl, + }) + assert.Nil(t, err) + defer client.Close() + + // create producer + js := new(JsonSchema) + schema, err := js.Serialize(testSchema{ + ID: 100, + Name: "pulsar", + }) + str := string(schema) + schemaJsonInfo := NewSchemaInfo("jsonTopic", str, JSON) Review comment: if so, When the user uses it, he can pass in the specified schema type, and avro will do the corresponding compatibility check? ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services