You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@eventmesh.apache.org by GitBox <gi...@apache.org> on 2022/04/03 14:18:05 UTC

[GitHub] [incubator-eventmesh] ruanwenjun commented on a change in pull request #821: [ISSUE #614] Add schema plugin and its api

ruanwenjun commented on a change in pull request #821:
URL: https://github.com/apache/incubator-eventmesh/pull/821#discussion_r841227912



##########
File path: eventmesh-schema-plugin/eventmesh-schema-api/src/main/java/org/apache/eventmesh/schema/api/SchemaPluginFactory.java
##########
@@ -0,0 +1,40 @@
+/*
+ * 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 org.apache.eventmesh.schema.api;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import org.apache.eventmesh.spi.EventMeshExtensionFactory;
+
+import lombok.experimental.UtilityClass;
+
+@UtilityClass
+public class SchemaPluginFactory {
+
+    /**
+     * Get {@code SchemaRegistry}
+     *
+     * @param schemaRegistryType the name of schema registry that configured in properties file
+     * @return schema registry plugin or null
+     */
+    public static SchemaRegistry getSchemaRegistry(String schemaRegistryType) {
+        checkNotNull(schemaRegistryType, "SchemaRegistryType cannot be null");
+        SchemaRegistry schemaRegistry = EventMeshExtensionFactory.getExtension(SchemaRegistry.class, schemaRegistryType);
+        return checkNotNull(schemaRegistry, "MetricsRegistryType: " + schemaRegistryType + " is not supported");
+    }

Review comment:
       ```suggestion
           return checkNotNull(schemaRegistry, "SchemaRegistryType: " + schemaRegistryType + " is not supported");
   ```

##########
File path: eventmesh-schema-plugin/eventmesh-schema-api/src/main/java/org/apache/eventmesh/schema/api/SchemaType.java
##########
@@ -0,0 +1,36 @@
+/*
+ * 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 org.apache.eventmesh.schema.api;
+
+import org.apache.commons.lang3.StringUtils;
+
+public enum SchemaType {
+    JSON("JSON"),
+    AVRO("AVRO"),
+    PROTOBUF("PROTOBUF");
+
+    private final String schemaTypeName;
+
+    SchemaType(String schemaTypeName) {
+        this.schemaTypeName = StringUtils.upperCase(StringUtils.deleteWhitespace(schemaTypeName));
+    }

Review comment:
       Use `this.schemaTypeName = schemaTypeName` is better.




-- 
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.

To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: dev-help@eventmesh.apache.org