pulsar-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [pulsar] sijie commented on a change in pull request #3904: [go schema] support go schema for pulsar-client-go
Date Tue, 09 Apr 2019 04:21:31 GMT
sijie 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_r273320217
 
 

 ##########
 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:
   @wolfstudy pulsar is using avro for storing schema definitions for struct schemas (avro,
json, and protobuf). the compatibility check is done by avro schema compatibility check. you
can check java's implementation.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message