mirror of
https://github.com/akvorado/akvorado.git
synced 2025-12-11 22:14:02 +01:00
``` goos: linux goarch: amd64 pkg: akvorado/orchestrator/clickhouse cpu: AMD Ryzen 5 5600X 6-Core Processor BenchmarkNetworks-12 482 2.447 ms/op ```
31 lines
765 B
Go
31 lines
765 B
Go
// SPDX-FileCopyrightText: 2022 Free Mobile
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
package clickhouse
|
|
|
|
import (
|
|
"context"
|
|
"net/netip"
|
|
|
|
"akvorado/common/remotedatasource"
|
|
)
|
|
|
|
type externalNetworkAttributes struct {
|
|
Prefix netip.Prefix
|
|
NetworkAttributes `mapstructure:",squash"`
|
|
}
|
|
|
|
// UpdateSource updates a remote network source. It returns the
|
|
// number of networks retrieved.
|
|
func (c *Component) UpdateSource(ctx context.Context, name string, source remotedatasource.Source) (int, error) {
|
|
results, err := c.networkSourcesFetcher.Fetch(ctx, name, source)
|
|
if err != nil {
|
|
return 0, err
|
|
}
|
|
c.networkSourcesLock.Lock()
|
|
c.networkSources[name] = results
|
|
c.networkSourcesLock.Unlock()
|
|
c.triggerNetworksCSVRefresh()
|
|
return len(results), nil
|
|
}
|