gonzojive opened a new issue, #21930:
URL: https://github.com/apache/beam/issues/21930

   ### What would you like to happen?
   
   
[coder.RegisterCoder](https://pkg.go.dev/github.com/apache/beam/sdks/v2/go/pkg/beam/core/graph/coder#RegisterCoder)
 should specify the accepted forms of the "enc" and "dec" arguments. Same for 
`NewCustomCoder`.
   
   ```go
   // RegisterCoder registers a user defined coder for a given type, and will
   // be used if there is no beam coder for that type. Must be called prior to 
beam.Init(),
   // preferably in an init() function.
   //
   // Coders are encoder and decoder pairs, and operate around []bytes.
   //
   // The coder used for a given type follows this ordering:
   //   1. Coders for Known Beam types.
   //   2. Coders registered for specific types
   //   3. Coders registered for interfaces types
   //   4. Default coder (JSON)
   //
   // Types of kind Interface, are handled specially by the registry, so they 
may be iterated
   // over to check if element types implement them.
   //
   // Repeated registrations of the same type overrides prior ones.
   ```
   
   ```go
   // NewCustomCoder creates a coder for the supplied parameters defining a
   // particular encoding strategy.
   ```
   
   The implementation seems to rely on this code:
   
   ```go
   func validateEncoder(t reflect.Type, encode interface{}) error {
        // Check if it uses the real type in question.
        if err := funcx.Satisfy(encode, funcx.Replace(encodeSig, typex.TType, 
t)); err != nil {
                return errors.WithContext(err, "validateEncoder: validating 
signature")
        }
        // TODO(lostluck): 2019.02.03 - Determine if there are encode 
allocation bottlenecks.
        return nil
   }
   
   func validateDecoder(t reflect.Type, decode interface{}) error {
        // Check if it uses the real type in question.
        if err := funcx.Satisfy(decode, funcx.Replace(decodeSig, typex.TType, 
t)); err != nil {
                return errors.WithContext(err, "validateDecoder: validating 
signature")
        }
        // TODO(lostluck): 2019.02.03 - Expand cases to avoid []byte -> 
interface{} conversion
        // in exec, & a beam Decoder interface.
        return nil
   }
   ```
   
   ### Issue Priority
   
   Priority: 2
   
   ### Issue Component
   
   Component: sdk-go


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to