Files
akvorado/orchestrator/clickhouse/source.go
Vincent Bernat f7cc5e3dbc orchestrator/clickhouse: add a benchmark for networks.csv
```
goos: linux
goarch: amd64
pkg: akvorado/orchestrator/clickhouse
cpu: AMD Ryzen 5 5600X 6-Core Processor
BenchmarkNetworks-12                 482                 2.447 ms/op
```
2025-08-17 11:05:58 +02:00

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
}