-
Notifications
You must be signed in to change notification settings - Fork 23
/
types.go
143 lines (114 loc) 路 2.89 KB
/
types.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
package libdream
import (
"context"
"sync"
commonIface "github.com/taubyte/go-interfaces/common"
"github.com/taubyte/go-interfaces/kvdb"
commonSpecs "github.com/taubyte/go-specs/common"
"github.com/taubyte/p2p/peer"
)
type Universe struct {
ctx context.Context
ctxC context.CancelFunc
lock sync.RWMutex
name string
root string
id string
all []peer.Node
closables []commonIface.Service
lookups map[string]*NodeInfo
portShift int
service map[string]*serviceInfo
simples map[string]*Simple
keepRoot bool
}
type serviceInfo struct {
nodes map[string]commonIface.Service
}
type handlers struct {
service ServiceCreate
client ClientCreate
}
type ServiceCreate func(*Universe, *commonIface.ServiceConfig) (commonIface.Service, error)
type ClientCreate func(peer.Node, *commonIface.ClientConfig) (commonIface.Client, error)
var Registry *handlerRegistry
type handlerRegistry struct {
registry map[string]*handlers
lock sync.RWMutex
}
// Order of params important!
type FixtureHandler func(universe *Universe, params ...interface{}) error
type FixtureVariable struct {
Name string
Alias string
Description string
Required bool
}
type FixtureDefinition struct {
Description string
ImportRef string
Variables []FixtureVariable
BlockCLI bool
Internal bool
}
type ClientCreationMethod func(*commonIface.ClientConfig) error
type SimpleConfig struct {
commonIface.CommonConfig
Clients map[string]*commonIface.ClientConfig
}
type NodeInfo struct {
DbFactory kvdb.Factory
Node peer.Node
Name string
Ports map[string]int
}
type Config struct {
Services map[string]commonIface.ServiceConfig
Simples map[string]SimpleConfig
}
type UniverseConfig struct {
Name string
Id string
KeepRoot bool
}
type serviceStatus struct {
Name string `json:"name"`
Copies int `json:"copies"`
}
type Multiverse struct{}
type Simple struct {
peer.Node
clients map[string]commonIface.Client
lock sync.RWMutex
}
// Deprecated use Map[string]*commonIface.ClientConfig{}
type SimpleConfigClients struct {
TNS *commonIface.ClientConfig
Auth *commonIface.ClientConfig
Seer *commonIface.ClientConfig
Patrick *commonIface.ClientConfig
Monkey *commonIface.ClientConfig
Hoarder *commonIface.ClientConfig
}
func (s SimpleConfigClients) Compat() map[string]*commonIface.ClientConfig {
newClientConfig := make(map[string]*commonIface.ClientConfig)
if s.TNS != nil {
newClientConfig[commonSpecs.TNS] = s.TNS
}
if s.Auth != nil {
newClientConfig[commonSpecs.Auth] = s.Auth
}
if s.Seer != nil {
newClientConfig[commonSpecs.Seer] = s.Seer
}
if s.Patrick != nil {
newClientConfig[commonSpecs.Patrick] = s.Patrick
}
if s.Monkey != nil {
newClientConfig[commonSpecs.Monkey] = s.Monkey
}
if s.Hoarder != nil {
newClientConfig[commonSpecs.Hoarder] = s.Hoarder
}
return newClientConfig
}