layer1: add namespace part helpers step 14
This commit is contained in:
@@ -19,6 +19,9 @@ type NamespaceManager interface {
|
||||
SnapshotSubscribers() []string
|
||||
Upsert(event NamespaceEvent) NamespaceRecord
|
||||
MarkPartState(namespace string, part string, state NamespacePartState) (NamespaceRecord, bool)
|
||||
MarkPartRegistering(namespace string, part string) (NamespaceRecord, bool)
|
||||
MarkPartActive(namespace string, part string) (NamespaceRecord, bool)
|
||||
MarkPartFailed(namespace string, part string, err error) (NamespaceRecord, bool)
|
||||
Remove(name string) bool
|
||||
}
|
||||
|
||||
@@ -184,6 +187,22 @@ func (m *inMemoryNamespaceManager) MarkPartState(namespace string, part string,
|
||||
return record.Clone(), true
|
||||
}
|
||||
|
||||
func (m *inMemoryNamespaceManager) MarkPartRegistering(namespace string, part string) (NamespaceRecord, bool) {
|
||||
return m.MarkPartState(namespace, part, NamespacePartState{State: NamespacePartStateRegistering})
|
||||
}
|
||||
|
||||
func (m *inMemoryNamespaceManager) MarkPartActive(namespace string, part string) (NamespaceRecord, bool) {
|
||||
return m.MarkPartState(namespace, part, NamespacePartState{State: NamespacePartStateActive})
|
||||
}
|
||||
|
||||
func (m *inMemoryNamespaceManager) MarkPartFailed(namespace string, part string, err error) (NamespaceRecord, bool) {
|
||||
lastError := ""
|
||||
if err != nil {
|
||||
lastError = err.Error()
|
||||
}
|
||||
return m.MarkPartState(namespace, part, NamespacePartState{State: NamespacePartStateFailed, LastError: lastError})
|
||||
}
|
||||
|
||||
func (m *inMemoryNamespaceManager) Remove(name string) bool {
|
||||
m.mu.Lock()
|
||||
defer m.mu.Unlock()
|
||||
@@ -219,4 +238,4 @@ func deriveNamespacePhase(record NamespaceRecord) NamespacePhase {
|
||||
}
|
||||
|
||||
return NamespacePhaseActive
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user