-
Notifications
You must be signed in to change notification settings - Fork 34
feat: add metadata to TaskHandler interface #70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅ |
I have read the CLA Document and I hereby sign the CLA |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Thanks for your contribution
@hyprh looks like the PR is failing on the |
@@ -72,6 +72,9 @@ type TaskHandler interface { | |||
|
|||
// GetContextID returns the context ID of the current message, if any. | |||
GetContextID() string | |||
|
|||
// GetMetadata returns the metadata of the current task. | |||
GetMetadata() (map[string]interface{}, error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about adopting a uniform style and replace interface{}
with any
? Since you had used metadata map[string]any
below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I did not noticed this comment and merged it , I will fix it.
// GetMetadata returns the metadata of the current request. | ||
func (h *memoryTaskHandler) GetMetadata() (map[string]interface{}, error) { | ||
if h.metadata == nil { | ||
return nil, fmt.Errorf("metadata is nil") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
errors.New("metadata is nil")
might be better
// GetMetadata returns the metadata of the current request. | ||
func (h *taskHandler) GetMetadata() (map[string]interface{}, error) { | ||
if h.metadata == nil { | ||
return nil, fmt.Errorf("metadata is nil") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
To retrieve metadata from incoming requests further in our handlers, we need to be able to set and retrieve it on the handler itself. This introduces an optional field called metadata, and a new method named GetMetadata().
Fixes #67
RELEASE NOTES: Allows retrieval of metadata from client requests throughout the handler lifecycle.