mirror of
https://github.com/hanzoai/tasks.git
synced 2026-10-04 02:04:03 +00:00
## What changed? Remove check for zero-length data in NewDataBlob. ## Why? Zero-length data is a valid encoding for some encodings, e.g. proto3. NewDataBlob should not have an opinion on the length of data. ## How did you test it? - [ ] built - [ ] run locally and tested manually - [ ] covered by existing tests - [ ] added new unit test(s) - [ ] added new functional test(s) ## Potential risks Some code may be making assumptions about this behavior.
22 lines
635 B
Go
22 lines
635 B
Go
package persistence
|
|
|
|
import (
|
|
commonpb "go.temporal.io/api/common/v1"
|
|
enumspb "go.temporal.io/api/enums/v1"
|
|
)
|
|
|
|
// NewDataBlob returns a new DataBlob.
|
|
// TODO: return an UnknowEncodingType error with the actual type string when encodingTypeStr is invalid
|
|
func NewDataBlob(data []byte, encodingTypeStr string) *commonpb.DataBlob {
|
|
encodingType, err := enumspb.EncodingTypeFromString(encodingTypeStr)
|
|
if err != nil {
|
|
// encodingTypeStr not valid, an error will be returned on deserialization
|
|
encodingType = enumspb.ENCODING_TYPE_UNSPECIFIED
|
|
}
|
|
|
|
return &commonpb.DataBlob{
|
|
Data: data,
|
|
EncodingType: encodingType,
|
|
}
|
|
}
|