func()

in grpc-xds/control-plane-go/pkg/xds/snapshot_cache.go [152:168]


func (c *SnapshotCache) createNewSnapshot(nodeHash string, apps []applications.Application) error {
	c.logger.Info("Creating a new snapshot", "nodeHash", nodeHash, "apps", apps)
	snapshotBuilder, err := NewSnapshotBuilder(nodeHash, c.localityPriorityMapper, c.features, c.authority).AddGRPCApplications(apps)
	if err != nil {
		return fmt.Errorf("could not create xDS resource snapshot builder for nodeHash=%s: %w", nodeHash, err)
	}
	snapshot, err := snapshotBuilder.
		AddGRPCServerListenerAddresses(c.grpcServerListenerCache.Get(nodeHash)).
		Build()
	if err != nil {
		return fmt.Errorf("could not create new xDS resource snapshot for nodeHash=%s: %w", nodeHash, err)
	}
	if err := c.delegate.SetSnapshot(c.ctx, nodeHash, snapshot); err != nil {
		return fmt.Errorf("could not set new xDS resource snapshot for nodeHash=%s: %w", nodeHash, err)
	}
	return nil
}