-
Notifications
You must be signed in to change notification settings - Fork 97
/
icomponent.go
98 lines (79 loc) · 2.42 KB
/
icomponent.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
89
90
91
92
93
94
95
96
97
98
package component
import "github.com/micro-plat/hydra/context"
//IComponent 提供一组或多组服务的组件
type IComponent interface {
AddCustomerService(service string, h interface{}, groupName string, tags ...string)
IsCustomerService(service string, group ...string) bool
GetFallbackHandlers() map[string]interface{}
AddFallbackHandlers(map[string]interface{})
LoadServices() error
GetRegistryNames(groups ...string) map[string][]string
GetGroupServices(group ...string) []string
GetServices() []string
GetGroups(service string) []string
GetTags(service string) []string
Fallback(c *context.Context) (rs interface{})
Handling(c *context.Context) (rs interface{})
Handled(c *context.Context) (rs interface{})
Handle(c *context.Context) interface{}
GetMeta(key string) interface{}
SetMeta(key string, value interface{})
Close() error
}
type CloseHandler interface {
Close() error
}
//Handler context handler
type Handler interface {
Handle(c *context.Context) interface{}
}
type IHandler interface {
Handle(c *context.Context) interface{}
}
type GetHandler interface {
GetHandle(c *context.Context) interface{}
}
type HeadHandler interface {
HeadHandle(c *context.Context) interface{}
}
type PostHandler interface {
PostHandle(c *context.Context) interface{}
}
type DeleteHandler interface {
DeleteHandle(c *context.Context) interface{}
}
type PutHandler interface {
PutHandle(c *context.Context) interface{}
}
//FallbackHandler context handler
type FallbackHandler interface {
Fallback(c *context.Context) interface{}
}
//GetFallbackHandler context handler
type GetFallbackHandler interface {
GetFallback(c *context.Context) interface{}
}
//PostFallbackHandler context handler
type PostFallbackHandler interface {
PostFallback(c *context.Context) interface{}
}
//PutFallbackHandler context handler
type PutFallbackHandler interface {
PutFallback(c *context.Context) interface{}
}
//DeleteFallbackHandler context handler
type DeleteFallbackHandler interface {
DeleteFallback(c *context.Context) interface{}
}
type FallbackServiceFunc func(c *context.Context) (rs interface{})
func (h FallbackServiceFunc) Fallback(c *context.Context) (rs interface{}) {
return h(c)
}
type ComponentFunc func(c IContainer) error
func (h ComponentFunc) Handle(c IContainer) error {
return h(c)
}
type ServiceFunc func(c *context.Context) (rs interface{})
func (h ServiceFunc) Handle(c *context.Context) (rs interface{}) {
return h(c)
}