2
0
mirror of https://github.com/hibiken/asynq.git synced 2025-10-03 05:12:01 +08:00

Add Hash method to Payload

This commit is contained in:
Ken Hibino
2019-12-20 20:14:40 -08:00
parent 14ac5f6674
commit 324a785233
3 changed files with 21 additions and 3 deletions

View File

@@ -19,6 +19,12 @@ func (e *errKeyNotFound) Error() string {
return fmt.Sprintf("key %q does not exist", e.key)
}
// Has reports whether key exists.
func (p Payload) Has(key string) bool {
_, ok := p[key]
return ok
}
// GetString returns a string value if a string type is associated with
// the key, otherwise reports an error.
func (p Payload) GetString(key string) (string, error) {