Newer
Older
"github.com/dubbo/go-for-apache-dubbo/common/constant"
"github.com/dubbo/go-for-apache-dubbo/config"
"github.com/dubbo/go-for-apache-dubbo/protocol"
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
)
/////////////////////////////
// Invocation Impletment of RPC
/////////////////////////////
// todo: is it necessary to separate fields of consumer(provider) from RPCInvocation
type RPCInvocation struct {
methodName string
parameterTypes []reflect.Type
arguments []interface{}
reply interface{}
callBack interface{}
attachments map[string]string
invoker protocol.Invoker
}
func NewRPCInvocationForConsumer(methodName string, parameterTypes []reflect.Type, arguments []interface{},
reply interface{}, callBack interface{}, url config.URL, invoker protocol.Invoker) *RPCInvocation {
attachments := map[string]string{}
attachments[constant.PATH_KEY] = url.Path
attachments[constant.GROUP_KEY] = url.GetParam(constant.GROUP_KEY, "")
attachments[constant.INTERFACE_KEY] = url.GetParam(constant.INTERFACE_KEY, "")
attachments[constant.VERSION_KEY] = url.GetParam(constant.VERSION_KEY, constant.DEFAULT_VERSION)
return &RPCInvocation{
methodName: methodName,
parameterTypes: parameterTypes,
arguments: arguments,
reply: reply,
callBack: callBack,
attachments: attachments,
invoker: invoker,
}
}
func NewRPCInvocationForProvider(url config.URL) *RPCInvocation {
attachments := map[string]string{}
attachments[constant.PATH_KEY] = url.Path
attachments[constant.GROUP_KEY] = url.GetParam(constant.GROUP_KEY, "")
attachments[constant.INTERFACE_KEY] = url.GetParam(constant.INTERFACE_KEY, "")
attachments[constant.VERSION_KEY] = url.GetParam(constant.VERSION_KEY, constant.DEFAULT_VERSION)
return &RPCInvocation{
attachments: attachments,
}
}
func (r *RPCInvocation) MethodName() string {
return r.methodName
}
func (r *RPCInvocation) ParameterTypes() []reflect.Type {
return r.parameterTypes
}
func (r *RPCInvocation) Arguments() []interface{} {
return r.arguments
}
func (r *RPCInvocation) Reply() interface{} {
return r.reply
}
func (r *RPCInvocation) Attachments() map[string]string {
return r.attachments
}
func (r *RPCInvocation) AttachmentsByKey(key string, defaultValue string) string {
if r.attachments == nil {
return defaultValue
}
value, ok := r.attachments[key]
if ok {
return value
}
return defaultValue
}
func (r *RPCInvocation) SetAttachments(key string, value string) {
if r.attachments == nil {
r.attachments = make(map[string]string)
}
r.attachments[key] = value
}
func (r *RPCInvocation) Invoker() protocol.Invoker {
return r.invoker
}
func (r *RPCInvocation) SetInvoker() protocol.Invoker {
return r.invoker
}
func (r *RPCInvocation) CallBack() interface{} {
return r.callBack
}