forked from hprose/hprose-golang
-
Notifications
You must be signed in to change notification settings - Fork 0
/
service_context.go
88 lines (76 loc) · 2.74 KB
/
service_context.go
1
2
3
4
5
6
7
8
9
10
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
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* rpc/service_context.go *
* *
* hprose service context for Go. *
* *
* LastModified: Nov 1, 2016 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
package rpc
// ServiceContext is the hprose service context
type ServiceContext interface {
Context
Service() Service
Clients() Clients
Method() *Method
IsMissingMethod() bool
ByRef() bool
setMethod(method *Method)
setIsMissingMethod(value bool)
setByRef(value bool)
}
// BaseServiceContext is the base service context
type BaseServiceContext struct {
BaseContext
method *Method
service Service
isMissingMethod bool
byRef bool
}
// InitServiceContext initializes BaseServiceContext
func (context *BaseServiceContext) InitServiceContext(service Service) {
context.InitBaseContext()
context.service = service
context.method = nil
context.isMissingMethod = false
context.byRef = false
}
// Method returns the method of current invoking
func (context *BaseServiceContext) Method() *Method {
return context.method
}
// Service returns the Service interface
func (context *BaseServiceContext) Service() Service {
return context.service
}
// Clients returns the Clients interface
func (context *BaseServiceContext) Clients() Clients {
return context.service
}
// IsMissingMethod returns whether the current invoking is missing method
func (context *BaseServiceContext) IsMissingMethod() bool {
return context.isMissingMethod
}
// ByRef returns whether the current invoking is parameter passing by reference.
func (context *BaseServiceContext) ByRef() bool {
return context.byRef
}
func (context *BaseServiceContext) setMethod(method *Method) {
context.method = method
}
func (context *BaseServiceContext) setIsMissingMethod(value bool) {
context.isMissingMethod = value
}
func (context *BaseServiceContext) setByRef(value bool) {
context.byRef = value
}