|
@@ -68,6 +68,7 @@ type network struct {
|
|
dbIndex uint64
|
|
dbIndex uint64
|
|
svcRecords svcMap
|
|
svcRecords svcMap
|
|
dbExists bool
|
|
dbExists bool
|
|
|
|
+ persist bool
|
|
stopWatchCh chan struct{}
|
|
stopWatchCh chan struct{}
|
|
dataScope datastore.DataScope
|
|
dataScope datastore.DataScope
|
|
sync.Mutex
|
|
sync.Mutex
|
|
@@ -141,6 +142,12 @@ func (n *network) Exists() bool {
|
|
return n.dbExists
|
|
return n.dbExists
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+func (n *network) Skip() bool {
|
|
|
|
+ n.Lock()
|
|
|
|
+ defer n.Unlock()
|
|
|
|
+ return !n.persist
|
|
|
|
+}
|
|
|
|
+
|
|
func (n *network) DataScope() datastore.DataScope {
|
|
func (n *network) DataScope() datastore.DataScope {
|
|
n.Lock()
|
|
n.Lock()
|
|
defer n.Unlock()
|
|
defer n.Unlock()
|
|
@@ -174,6 +181,7 @@ func (n *network) MarshalJSON() ([]byte, error) {
|
|
netMap["endpointCnt"] = n.endpointCnt
|
|
netMap["endpointCnt"] = n.endpointCnt
|
|
netMap["enableIPv6"] = n.enableIPv6
|
|
netMap["enableIPv6"] = n.enableIPv6
|
|
netMap["generic"] = n.generic
|
|
netMap["generic"] = n.generic
|
|
|
|
+ netMap["persist"] = n.persist
|
|
return json.Marshal(netMap)
|
|
return json.Marshal(netMap)
|
|
}
|
|
}
|
|
|
|
|
|
@@ -191,6 +199,9 @@ func (n *network) UnmarshalJSON(b []byte) (err error) {
|
|
if netMap["generic"] != nil {
|
|
if netMap["generic"] != nil {
|
|
n.generic = netMap["generic"].(map[string]interface{})
|
|
n.generic = netMap["generic"].(map[string]interface{})
|
|
}
|
|
}
|
|
|
|
+ if netMap["persist"] != nil {
|
|
|
|
+ n.persist = netMap["persist"].(bool)
|
|
|
|
+ }
|
|
return nil
|
|
return nil
|
|
}
|
|
}
|
|
|
|
|
|
@@ -210,6 +221,13 @@ func NetworkOptionGeneric(generic map[string]interface{}) NetworkOption {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// NetworkOptionPersist returns an option setter to set persistence policy for a network
|
|
|
|
+func NetworkOptionPersist(persist bool) NetworkOption {
|
|
|
|
+ return func(n *network) {
|
|
|
|
+ n.persist = persist
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
func (n *network) processOptions(options ...NetworkOption) {
|
|
func (n *network) processOptions(options ...NetworkOption) {
|
|
for _, opt := range options {
|
|
for _, opt := range options {
|
|
if opt != nil {
|
|
if opt != nil {
|