You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by GitBox <gi...@apache.org> on 2020/03/13 22:49:07 UTC

[GitHub] [beam] jfarr commented on a change in pull request #9758: [BEAM-8374] Enable returning missing PublishResult fields in SnsIO.Write

jfarr commented on a change in pull request #9758: [BEAM-8374] Enable returning missing PublishResult fields in SnsIO.Write
URL: https://github.com/apache/beam/pull/9758#discussion_r392518426
 
 

 ##########
 File path: sdks/java/io/amazon-web-services/src/main/java/org/apache/beam/sdk/io/aws/coders/AwsCoders.java
 ##########
 @@ -0,0 +1,138 @@
+/*
+ * 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.beam.sdk.io.aws.coders;
+
+import com.amazonaws.ResponseMetadata;
+import com.amazonaws.http.HttpResponse;
+import com.amazonaws.http.SdkHttpMetadata;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Map;
+import java.util.Optional;
+import org.apache.beam.sdk.coders.AtomicCoder;
+import org.apache.beam.sdk.coders.Coder;
+import org.apache.beam.sdk.coders.CoderException;
+import org.apache.beam.sdk.coders.CustomCoder;
+import org.apache.beam.sdk.coders.MapCoder;
+import org.apache.beam.sdk.coders.NullableCoder;
+import org.apache.beam.sdk.coders.StringUtf8Coder;
+import org.apache.beam.sdk.coders.VarIntCoder;
+import org.apache.beam.vendor.guava.v26_0_jre.com.google.common.collect.ImmutableMap;
+
+/** {@link Coder}s for common AWS SDK objects. */
+public final class AwsCoders {
+
+  private AwsCoders() {}
+
+  /**
+   * Returns a new coder for ResponseMetadata.
+   *
+   * @return the ResponseMetadata coder
+   */
+  public static Coder<ResponseMetadata> responseMetadata() {
+    return ResponseMetadataCoder.of();
+  }
+
+  /**
+   * Returns a new coder for SdkHttpMetadata.
+   *
+   * @return the SdkHttpMetadata coder
+   */
+  public static Coder<SdkHttpMetadata> sdkHttpMetadata() {
+    return new SdkHttpMetadataCoder(true);
 
 Review comment:
   @cmachgodaddy That's because this class is designed as a factory for coders, with the coder implementation being an internal detail, as @lukecwik suggested in an earlier comment thread.
   
   > Style note, you can create one class called `AwsCoders` which has three static methods `minimalSdkHttpMetadata()` and `fullSdkHttpMetadata()` and `responseMetadata()` that return the coders. This way you can make all the coder implementations private inner static classes and they all become implementation details without needing to expose them to users. Users can still get an instance if they need one but it gives us flexibility from a maintenance point of view how the coders are organized.
   
   I could create a static factory method `of()` on SdkHttpMetadata but it wouldn't serve any purpose, it would only be called by sdkHttpMetadata() which is already a static factory method. SdkHttpMetadata is not meant to be instantiated directly by the caller.

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