forked from andradeandrey/fwk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
svcbase.go
57 lines (47 loc) · 1.29 KB
/
svcbase.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
package fwk
import (
"github.com/go-hep/fwk/fsm"
)
// SvcBase provides a base implementation for fwk.Svc
type SvcBase struct {
t string
n string
mgr App
}
// NewSvc creates a new SvcBase of type typ and name name,
// managed by the fwk.App mgr.
func NewSvc(typ, name string, mgr App) SvcBase {
return SvcBase{
t: typ,
n: name,
mgr: mgr,
}
}
// Type returns the fully qualified type of the underlying service.
// e.g. "github.com/go-hep/fwk/testdata.svc1"
func (svc *SvcBase) Type() string {
return svc.t
}
// Name returns the name of the underlying service.
// e.g. "my-service"
func (svc *SvcBase) Name() string {
return svc.n
}
// DeclProp declares this service has a property named n,
// and takes a pointer to the associated value.
func (svc *SvcBase) DeclProp(n string, ptr interface{}) error {
return svc.mgr.DeclProp(svc, n, ptr)
}
// SetProp sets the property name n with the value v.
func (svc *SvcBase) SetProp(name string, value interface{}) error {
return svc.mgr.SetProp(svc, name, value)
}
// GetProp returns the value of the property named n.
func (svc *SvcBase) GetProp(name string) (interface{}, error) {
return svc.mgr.GetProp(svc, name)
}
// FSMState returns the current state of the FSM
func (svc *SvcBase) FSMState() fsm.State {
return svc.mgr.FSMState()
}
// EOF