Skip to content
Snippets Groups Projects
Commit a78109fa authored by cvictory's avatar cvictory
Browse files

add default value of attribute

parent e226771b
No related branches found
No related tags found
No related merge requests found
......@@ -52,6 +52,7 @@ func NewRPCInvocation(methodName string, arguments []interface{}, attachments ma
methodName: methodName,
arguments: arguments,
attachments: attachments,
attributes: make(map[string]interface{}, 8),
}
}
......@@ -142,6 +143,16 @@ func (r *RPCInvocation) SetAttachments(key string, value string) {
r.attachments[key] = value
}
// SetAttribute. If Attributes is nil, it will be inited.
func (r *RPCInvocation) SetAttribute(key string, value interface{}) {
r.lock.Lock()
defer r.lock.Unlock()
if r.attributes == nil {
r.attributes = make(map[string]interface{})
}
r.attributes[key] = value
}
// Invoker ...
func (r *RPCInvocation) Invoker() protocol.Invoker {
return r.invoker
......@@ -217,6 +228,12 @@ func WithAttachments(attachments map[string]string) option {
}
}
func WithAttributes(attributes map[string]interface{}) option {
return func(invo *RPCInvocation) {
invo.attributes = attributes
}
}
// WithInvoker ...
func WithInvoker(invoker protocol.Invoker) option {
return func(invo *RPCInvocation) {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment