@@ -59,7 +59,6 @@ type AsyncCallback func(response CallbackResponse)
59
59
// return map[string][string]{}
60
60
// }
61
61
const (
62
- // METHOD_MAPPER ...
63
62
METHOD_MAPPER = "MethodMapper"
64
63
)
65
64
68
67
// because Typeof takes an empty interface value. This is annoying.
69
68
typeOfError = reflect .TypeOf ((* error )(nil )).Elem ()
70
69
71
- // ServiceMap .. .
70
+ // ServiceMap store description of service .
72
71
// todo: lowerecas?
73
72
ServiceMap = & serviceMap {
74
73
serviceMap : make (map [string ]map [string ]* Service ),
@@ -80,35 +79,35 @@ var (
80
79
// info of method
81
80
//////////////////////////
82
81
83
- // MethodType .. .
82
+ // MethodType is description of service method .
84
83
type MethodType struct {
85
84
method reflect.Method
86
85
ctxType reflect.Type // request context
87
86
argsType []reflect.Type // args except ctx, include replyType if existing
88
87
replyType reflect.Type // return value, otherwise it is nil
89
88
}
90
89
91
- // Method .. .
90
+ // Method get @m.method .
92
91
func (m * MethodType ) Method () reflect.Method {
93
92
return m .method
94
93
}
95
94
96
- // CtxType .. .
95
+ // CtxType get @m.ctxType .
97
96
func (m * MethodType ) CtxType () reflect.Type {
98
97
return m .ctxType
99
98
}
100
99
101
- // ArgsType .. .
100
+ // ArgsType get @m.argsType .
102
101
func (m * MethodType ) ArgsType () []reflect.Type {
103
102
return m .argsType
104
103
}
105
104
106
- // ReplyType .. .
105
+ // ReplyType get @m.replyType .
107
106
func (m * MethodType ) ReplyType () reflect.Type {
108
107
return m .replyType
109
108
}
110
109
111
- // SuiteContext .. .
110
+ // SuiteContext tranfer @ctx to reflect.Value type or get it from @m.ctxType .
112
111
func (m * MethodType ) SuiteContext (ctx context.Context ) reflect.Value {
113
112
if contextv := reflect .ValueOf (ctx ); contextv .IsValid () {
114
113
return contextv
@@ -120,25 +119,25 @@ func (m *MethodType) SuiteContext(ctx context.Context) reflect.Value {
120
119
// info of service interface
121
120
//////////////////////////
122
121
123
- // Service ...
122
+ // Service is description of service
124
123
type Service struct {
125
124
name string
126
125
rcvr reflect.Value
127
126
rcvrType reflect.Type
128
127
methods map [string ]* MethodType
129
128
}
130
129
131
- // Method .. .
130
+ // Method get @s.methods .
132
131
func (s * Service ) Method () map [string ]* MethodType {
133
132
return s .methods
134
133
}
135
134
136
- // RcvrType .. .
135
+ // RcvrType get @s.rcvrType .
137
136
func (s * Service ) RcvrType () reflect.Type {
138
137
return s .rcvrType
139
138
}
140
139
141
- // Rcvr .. .
140
+ // Rcvr get @s.rcvr .
142
141
func (s * Service ) Rcvr () reflect.Value {
143
142
return s .rcvr
144
143
}
@@ -274,7 +273,9 @@ func (sm *serviceMap) UnRegister(interfaceName, protocol, serviceId string) erro
274
273
}
275
274
}
276
275
delete (svcs , serviceId )
277
- delete (sm .serviceMap , protocol )
276
+ if len (sm .serviceMap ) == 0 {
277
+ delete (sm .serviceMap , protocol )
278
+ }
278
279
279
280
return nil
280
281
}
0 commit comments