google.golang.org/grpc@v1.72.2/xds/internal/clients/xdsclient/resource_watcher.go (about) 1 /* 2 * 3 * Copyright 2025 gRPC authors. 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 * 17 */ 18 19 package xdsclient 20 21 // ResourceWatcher is notified of the resource updates and errors that are 22 // received by the xDS client from the management server. 23 // 24 // All methods contain a done parameter which should be called when processing 25 // of the update has completed. For example, if processing a resource requires 26 // watching new resources, those watches should be completed before done is 27 // called, which can happen after the ResourceWatcher method has returned. 28 // Failure to call done will prevent the xDS client from providing future 29 // ResourceWatcher notifications. 30 type ResourceWatcher interface { 31 // ResourceChanged indicates a new version of the resource is available. 32 ResourceChanged(resourceData ResourceData, done func()) 33 34 // ResourceError indicates an error occurred while trying to fetch or 35 // decode the associated resource. The previous version of the resource 36 // should be considered invalid. 37 ResourceError(err error, done func()) 38 39 // AmbientError indicates an error occurred after a resource has been 40 // received that should not modify the use of that resource but may provide 41 // useful information about the state of the XDSClient for debugging 42 // purposes. The previous version of the resource should still be 43 // considered valid. 44 AmbientError(err error, done func()) 45 }