layer1: add namespace lifecycle subscribers step 16
This commit is contained in:
@@ -0,0 +1,18 @@
|
|||||||
|
# 2026-04-26 — NamespaceManager rewrite, step 16
|
||||||
|
|
||||||
|
## Цель шага
|
||||||
|
|
||||||
|
Подготовить lifecycle subscriber contract для будущего reconcile path.
|
||||||
|
|
||||||
|
## Что меняем
|
||||||
|
|
||||||
|
1. Расширяем `NamespaceSubscriber` методами:
|
||||||
|
- `OnNamespaceAdd()`
|
||||||
|
- `OnNamespaceRemove()`
|
||||||
|
- `OnNamespaceResync()`
|
||||||
|
2. Обновляем тестовую заглушку subscriber-а.
|
||||||
|
|
||||||
|
## Что НЕ меняем
|
||||||
|
|
||||||
|
- не вызываем subscriber-ов из manager;
|
||||||
|
- не подключаем contract к runtime components.
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package utils
|
package utils
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"sort"
|
"sort"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
@@ -8,6 +9,9 @@ import (
|
|||||||
|
|
||||||
type NamespaceSubscriber interface {
|
type NamespaceSubscriber interface {
|
||||||
Name() string
|
Name() string
|
||||||
|
OnNamespaceAdd(ctx context.Context, record NamespaceRecord) error
|
||||||
|
OnNamespaceRemove(ctx context.Context, record NamespaceRecord) error
|
||||||
|
OnNamespaceResync(ctx context.Context, record NamespaceRecord) error
|
||||||
}
|
}
|
||||||
|
|
||||||
type NamespaceManager interface {
|
type NamespaceManager interface {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package utils
|
package utils
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
@@ -15,6 +16,18 @@ func (s testNamespaceSubscriber) Name() string {
|
|||||||
return s.name
|
return s.name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s testNamespaceSubscriber) OnNamespaceAdd(ctx context.Context, record NamespaceRecord) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s testNamespaceSubscriber) OnNamespaceRemove(ctx context.Context, record NamespaceRecord) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s testNamespaceSubscriber) OnNamespaceResync(ctx context.Context, record NamespaceRecord) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func TestNamespaceManagerSnapshotAndGet(t *testing.T) {
|
func TestNamespaceManagerSnapshotAndGet(t *testing.T) {
|
||||||
manager := NewNamespaceManager()
|
manager := NewNamespaceManager()
|
||||||
now := time.Now().UTC()
|
now := time.Now().UTC()
|
||||||
|
|||||||
Reference in New Issue
Block a user