Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions converter/value.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,22 @@ func (v RawValue) MarshalJSON() ([]byte, error) {
func (v *RawValue) UnmarshalJSON(b []byte) error {
return fmt.Errorf("RawValue is not JSON serializable")
}

// ValuesPayloads is an optional interface that EncodedValue and EncodedValues may implement
// to expose the underlying commonpb.Payloads without decoding.
type ValuesPayloads interface {
// Payloads gets the underlying commonpb.Payloads
Payloads() *commonpb.Payloads
}

// GetPayloads acts as a helper to extract the raw *commonpb.Payloads from an EncodedValue
// or EncodedValues, if the underlying implementation supports it via the ValuesPayloads interface.
// If the underlying implementation does not support it, this returns nil.
//
// Exposed as: [go.temporal.io/sdk/converter.GetPayloads]
func GetPayloads(encoded interface{}) *commonpb.Payloads {
if vp, ok := encoded.(ValuesPayloads); ok {
return vp.Payloads()
}
return nil
}
4 changes: 4 additions & 0 deletions internal/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,10 @@ func (e *temporalError) failure() *failurepb.Failure {
return e.originalFailure
}

func (e *temporalError) Failure() *failurepb.Failure {
return e.originalFailure
}

// IsCanceledError returns whether error in CanceledError.
func IsCanceledError(err error) bool {
var canceledErr *CanceledError
Expand Down
5 changes: 5 additions & 0 deletions internal/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -2132,6 +2132,11 @@ func (b EncodedValue) HasValue() bool {
return b.value != nil
}

// Payloads gets the underlying commonpb.Payloads
func (b EncodedValue) Payloads() *commonpb.Payloads {
return b.value
}

// SideEffect executes the provided function once, records its result into the workflow history. The recorded result on
// history will be returned without executing the provided function during replay. This guarantees the deterministic
// requirement for workflow as the exact same result will be returned in replay.
Expand Down
14 changes: 12 additions & 2 deletions internal/workflow_testsuite.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,16 @@ func (b EncodedValues) Get(valuePtr ...interface{}) error {
return b.dataConverter.FromPayloads(b.values, valuePtr...)
}

// HasValues return whether there are values
// HasValues return whether there are values encoded.
func (b EncodedValues) HasValues() bool {
return b.values != nil
}

// Payloads gets the underlying commonpb.Payloads
func (b EncodedValues) Payloads() *commonpb.Payloads {
return b.values
}

// Get extract data from encoded data to desired value type. valuePtr is pointer to the actual value type.
func (b ErrorDetailsValues) Get(valuePtr ...interface{}) error {
if !b.HasValues() {
Expand All @@ -117,11 +122,16 @@ func (b ErrorDetailsValues) Get(valuePtr ...interface{}) error {
return nil
}

// HasValues return whether there are values.
// HasValues return whether there are values encoded.
func (b ErrorDetailsValues) HasValues() bool {
return len(b) != 0
}

// Payloads gets the underlying commonpb.Payloads
func (b ErrorDetailsValues) Payloads() *commonpb.Payloads {
return nil
}

// NewTestWorkflowEnvironment creates a new instance of TestWorkflowEnvironment. Use the returned TestWorkflowEnvironment
// to run your workflow in the test environment.
func (s *WorkflowTestSuite) NewTestWorkflowEnvironment() *TestWorkflowEnvironment {
Expand Down
25 changes: 24 additions & 1 deletion mocks/Value.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading