You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@thrift.apache.org by GitBox <gi...@apache.org> on 2022/10/12 22:31:03 UTC

[GitHub] [thrift] fishy commented on a diff in pull request #2708: THRIFT-5650: Implement UUID in Go library

fishy commented on code in PR #2708:
URL: https://github.com/apache/thrift/pull/2708#discussion_r993947680


##########
lib/go/thrift/uuid.go:
##########
@@ -0,0 +1,115 @@
+/*
+ * 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 thrift
+
+import (
+	"encoding/hex"
+	"fmt"
+)
+
+// Tuuid is a minimal implementation of UUID for thrift's read/write operations.
+//
+// This implementation only covers read/write in various thrift protocols.
+// If you need to generate/manipulate/etc. an UUID,
+// you likely would need a third party UUID library instead.
+//
+// This type should be directly cast-able with most popular third party UUID
+// libraries.
+// For example, assuming you are using
+// https://pkg.go.dev/github.com/google/uuid to generate a v4 UUID for an
+// optional thrift field:
+//
+//	id, err := uuid.NewRandom()
+//	if err != nil {
+//	  // TODO: handle errors
+//	}
+//	myRequest.Uuid = thrift.Pointer(thrift.Tuuid(id))
+type Tuuid [16]byte

Review Comment:
   I'm not super happy with the name here, but the reality is that we have a type (here) and a constant (the value of TType enum) both should be named `UUID`, and only one of them can be named `UUID` and the other need to find a different name.
   
   I think it's better to change the type name to `Tuuid`, as a way to emphasize that this is not really a full UUID implementation. @dcelasun what do you think?



##########
lib/go/test/tests/protocol_mock.go:
##########
@@ -1,513 +1,703 @@
-/*
- * 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.
- */
-
-// Automatically generated by MockGen. DO NOT EDIT!
-// Source: thrift (interfaces: TProtocol)
+// Code generated by MockGen. DO NOT EDIT.

Review Comment:
   Since we updated `TProtocol` and have to rerun mockgen, I keep this file to be the exact output of mockgen, and thus removed the license header.
   
   @Jens-G I'm not 100% sure if that's in compliance to Apache license policy (this file is purely machine generated). if that's not allowed, I can add the license header back.



-- 
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: notifications-unsubscribe@thrift.apache.org

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