MCPcopy Create free account
hub / github.com/apache/dubbo-go / GetAttachment

Method GetAttachment

protocol/invocation/rpcinvocation.go:191–206  ·  view source on GitHub ↗
(key string)

Source from the content-addressed store, hash-verified

189}
190
191func (r *RPCInvocation) GetAttachment(key string) (string, bool) {
192 r.lock.RLock()
193 defer r.lock.RUnlock()
194 if r.attachments == nil {
195 return "", false
196 }
197 if value, existed := r.attachments[key]; existed {
198 if str, strOK := value.(string); strOK {
199 return str, true
200 } else if strArr, strArrOK := value.([]string); strArrOK && len(strArr) > 0 {
201 // For triple protocol, the attachment value is wrapped by an array.
202 return strArr[0], true
203 }
204 }
205 return "", false
206}
207
208func (r *RPCInvocation) GetAttachmentWithDefaultValue(key string, defaultValue string) string {
209 if value, ok := r.GetAttachment(key); ok {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected