...

Source file src/google.golang.org/grpc/xds/internal/xdsclient/client.go

Documentation: google.golang.org/grpc/xds/internal/xdsclient

     1  /*
     2   *
     3   * Copyright 2019 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 implements a full fledged gRPC client for the xDS API used
    20  // by the xds resolver and balancer implementations.
    21  package xdsclient
    22  
    23  import (
    24  	"google.golang.org/grpc/internal/xds/bootstrap"
    25  	"google.golang.org/grpc/xds/internal/xdsclient/load"
    26  	"google.golang.org/grpc/xds/internal/xdsclient/xdsresource"
    27  )
    28  
    29  // XDSClient is a full fledged gRPC client which queries a set of discovery APIs
    30  // (collectively termed as xDS) on a remote management server, to discover
    31  // various dynamic resources.
    32  type XDSClient interface {
    33  	// WatchResource uses xDS to discover the resource associated with the
    34  	// provided resource name. The resource type implementation determines how
    35  	// xDS requests are sent out and how responses are deserialized and
    36  	// validated. Upon receipt of a response from the management server, an
    37  	// appropriate callback on the watcher is invoked.
    38  	//
    39  	// Most callers will not have a need to use this API directly. They will
    40  	// instead use a resource-type-specific wrapper API provided by the relevant
    41  	// resource type implementation.
    42  	//
    43  	//
    44  	// During a race (e.g. an xDS response is received while the user is calling
    45  	// cancel()), there's a small window where the callback can be called after
    46  	// the watcher is canceled. Callers need to handle this case.
    47  	WatchResource(rType xdsresource.Type, resourceName string, watcher xdsresource.ResourceWatcher) (cancel func())
    48  
    49  	// DumpResources returns the status of the xDS resources. Returns a map of
    50  	// resource type URLs to a map of resource names to resource state.
    51  	DumpResources() map[string]map[string]xdsresource.UpdateWithMD
    52  
    53  	ReportLoad(*bootstrap.ServerConfig) (*load.Store, func())
    54  
    55  	BootstrapConfig() *bootstrap.Config
    56  }
    57  

View as plain text