feat: add tenant refresh functionality to HTTP API and job processing
CI / changes (push) Successful in 11s
CI / openapi (push) Has been skipped
CI / go (push) Successful in 59s
CI / docker-web (deploy/docker/evobgp-web/Dockerfile, , evobgp-web) (push) Has been skipped
CI / docker-bird (push) Has been skipped
CI / docker-web (deploy/docker/evobgp-web/Dockerfile, evobgp-all, evobgp-web-all) (push) Has been skipped
CI / bird2 (push) Successful in 43s
CI / docker-go (evobgp-all, 1, deploy/docker/gobinary/Dockerfile, , evobgp-all) (push) Has been skipped
CI / docker-go (evobgp-api, 1, deploy/docker/gobinary/Dockerfile, , evobgp-api) (push) Has been skipped
CI / docker-go (evobgp-deploy, 0, deploy/docker/gobinary/Dockerfile, , evobgp-deploy) (push) Has been skipped
CI / docker-go (evobgp-ingest, 0, deploy/docker/gobinary/Dockerfile, , evobgp-ingest) (push) Has been skipped
CI / docker-go (evobgp-node, 0, deploy/docker/gobinary/Dockerfile, , evobgp-node) (push) Has been skipped
CI / docker-go (evobgp-render, 0, deploy/docker/gobinary/Dockerfile, , evobgp-render) (push) Has been skipped
CI / docker-go (evobgp-scheduler, 0, deploy/docker/gobinary/Dockerfile, , evobgp-scheduler) (push) Has been skipped
CI / docker-go-prime (push) Successful in 55s
CI / docker-go (deploy/docker/evobgp-agent/Dockerfile, , evobgp-agent) (push) Has been cancelled

Implemented a new endpoint for tenant refresh in the HTTP API, allowing for the refresh of modules associated with a tenant. Enhanced job processing to handle tenant refresh jobs, including logic for managing module IDs and job status updates. Updated the scheduler to enqueue tenant refresh jobs based on module due dates, improving the overall efficiency of module management. Additionally, introduced caching for ASN prefix data to optimize performance during refresh operations.
This commit is contained in:
Denozordec
2026-05-19 10:35:20 +07:00
parent ee364c8b6d
commit 7a2b015b12
21 changed files with 774 additions and 155 deletions
+12
View File
@@ -84,6 +84,18 @@ type Backend interface {
GetModulePrefixSnapshot(tenantID, moduleID string) (*ModulePrefixSnapshot, bool, error)
SetModulePrefixSnapshot(tenantID, moduleID, inputHash string, prefixes []PrefixRow) error
DeleteModulePrefixSnapshot(tenantID, moduleID string) error
// ASNPrefixCache stores RIPEstat announced-prefixes per ASN (global TTL cache).
GetASNPrefixCache(asn int64) (*ASNPrefixCacheEntry, bool, error)
SetASNPrefixCache(asn int64, holder string, prefixes []string) error
}
// ASNPrefixCacheEntry is a cached RIPEstat response for one ASN.
type ASNPrefixCacheEntry struct {
ASN int64
Holder string
Prefixes []string
FetchedAt time.Time
}
// ModulePrefixSnapshot is the cached materialization for one module between refreshes.
+2
View File
@@ -41,6 +41,7 @@ type Memory struct {
settings map[string]map[string]any // tenantID -> key -> JSON-compatible value
revPrefixes map[string][]PrefixRow
moduleSnapshots map[string]*moduleSnapshotRec
asnPrefixCache map[int64]*ASNPrefixCacheEntry
// DemoIDs valid after SeedDemo()
demoTenantID string
@@ -128,6 +129,7 @@ func NewMemory() *Memory {
settings: make(map[string]map[string]any),
revPrefixes: make(map[string][]PrefixRow),
moduleSnapshots: make(map[string]*moduleSnapshotRec),
asnPrefixCache: make(map[int64]*ASNPrefixCacheEntry),
}
}
+40
View File
@@ -0,0 +1,40 @@
package store
import (
"time"
)
func (m *Memory) GetASNPrefixCache(asn int64) (*ASNPrefixCacheEntry, bool, error) {
m.mu.RLock()
defer m.mu.RUnlock()
if m.asnPrefixCache == nil {
return nil, false, nil
}
e, ok := m.asnPrefixCache[asn]
if !ok || e == nil {
return nil, false, nil
}
pfx := append([]string(nil), e.Prefixes...)
return &ASNPrefixCacheEntry{
ASN: asn,
Holder: e.Holder,
Prefixes: pfx,
FetchedAt: e.FetchedAt,
}, true, nil
}
func (m *Memory) SetASNPrefixCache(asn int64, holder string, prefixes []string) error {
m.mu.Lock()
defer m.mu.Unlock()
if m.asnPrefixCache == nil {
m.asnPrefixCache = make(map[int64]*ASNPrefixCacheEntry)
}
cp := append([]string(nil), prefixes...)
m.asnPrefixCache[asn] = &ASNPrefixCacheEntry{
ASN: asn,
Holder: holder,
Prefixes: cp,
FetchedAt: time.Now().UTC(),
}
return nil
}