-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deprecated: queues.WorkflowSignal, use queue.Signal
- Loading branch information
1 parent
b5ce101
commit ef4c174
Showing
5 changed files
with
141 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,78 @@ | ||
package queues | ||
|
||
import ( | ||
"encoding/json" | ||
) | ||
|
||
type ( | ||
// WorkflowSignal is a string alias intended for defining groups of workflow signals. | ||
// | ||
// Depraecated: Use Signal instead. | ||
WorkflowSignal string | ||
|
||
// Signal is a string alias intended for defining groups of workflow signals, "register" , "send_welcome_email" etc. | ||
// It ensures consistency and code clarity. The Signal type provides methods for conversion and serialization, | ||
// promoting good developer experience. | ||
Signal string | ||
|
||
// Query is a string alias intended for defining groups of workflow queries. We could have created an alias for | ||
// for Signal type, but for some wierd reason, if was causing temporal to panic when marshalling the type to JSON. | ||
Query string | ||
) | ||
|
||
func (s WorkflowSignal) String() string { | ||
return string(s) | ||
} | ||
|
||
func (s WorkflowSignal) MarshalJSON() ([]byte, error) { | ||
return []byte(s.String()), nil | ||
return json.Marshal(string(s)) | ||
} | ||
|
||
func (s *WorkflowSignal) UnmarshalJSON(data []byte) error { | ||
*s = WorkflowSignal(data) | ||
var str string | ||
if err := json.Unmarshal(data, &str); err != nil { | ||
return err | ||
} | ||
|
||
*s = WorkflowSignal(str) | ||
|
||
return nil | ||
} | ||
|
||
func (s Signal) String() string { | ||
return string(s) | ||
} | ||
|
||
func (s Signal) MarshalJSON() ([]byte, error) { | ||
return json.Marshal(string(s)) | ||
} | ||
|
||
func (s *Signal) UnmarshalJSON(data []byte) error { | ||
var str string | ||
if err := json.Unmarshal(data, &str); err != nil { | ||
return err | ||
} | ||
|
||
*s = Signal(str) | ||
|
||
return nil | ||
} | ||
|
||
func (q Query) String() string { | ||
return string(q) | ||
} | ||
|
||
func (q Query) MarshalJSON() ([]byte, error) { | ||
return json.Marshal(string(q)) | ||
} | ||
|
||
func (q *Query) UnmarshalJSON(data []byte) error { | ||
var str string | ||
if err := json.Unmarshal(data, &str); err != nil { | ||
return err | ||
} | ||
|
||
*q = Query(str) | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.