ni.measurementlink.discovery.v1.client
Public API for accessing the NI Discovery Service.
Classes
Client for accessing the NI Discovery Service. |
|
Represents a compute node. |
|
A named tuple providing information about a registered service. |
|
Represents the location of a service. |
Package Contents
- class ni.measurementlink.discovery.v1.client.DiscoveryClient(stub=None, *, grpc_channel_pool=None)[source]
Client for accessing the NI Discovery Service.
Initialize the discovery client.
- Parameters:
stub (ni.measurementlink.discovery.v1.discovery_service_pb2_grpc.DiscoveryServiceStub | None) – An optional discovery service gRPC stub for unit testing.
grpc_channel_pool (ni_grpc_extensions.channelpool.GrpcChannelPool | None) – An optional gRPC channel pool (recommended).
- __slots__ = ['_initialization_lock', '_grpc_channel_pool', '_stub', '__weakref__']
- register_service(service_info, service_location)[source]
Register the specified service with the discovery service.
- Parameters:
service_info (ni.measurementlink.discovery.v1.client._types.ServiceInfo) – Information describing the service.
service_location (ni.measurementlink.discovery.v1.client._types.ServiceLocation) – The location of the service on the network.
- Returns:
ID that can be used to unregister the service.
- Return type:
- unregister_service(registration_id)[source]
Unregisters the specified service from the discovery service.
This method should be called before the service exits.
- resolve_service(provided_interface, service_class='', deployment_target='', version='')[source]
Resolve the location of a service.
Given a description of a service, returns information that can be used to establish communication with that service. If necessary, the service will be started by the discovery service if it has not already been started.
- Parameters:
provided_interface (str) – The gRPC full name of the service.
service_class (str) – The service “class” that should be matched. If the value is not specified and there is more than one matching service registered, an error is returned.
deployment_target (str) – The deployment target from which the service should be resolved. Callers should pass either the url string from a
ComputeNodeSpecifieror a blank string for local execution.version (str) – The version of the service to resolve. If not specified, the latest version will be resolved.
- Returns:
The service location.
- Return type:
ni.measurementlink.discovery.v1.client._types.ServiceLocation
- resolve_service_with_information(provided_interface, service_class='', deployment_target='', version='')[source]
Resolve the location of a service along with its information.
Given a description of a service, returns information for the service in addition to the location of the service. If necessary, the service will be started by the discovery service if it has not already been started.
- Parameters:
provided_interface (str) – The gRPC full name of the service.
service_class (str) – The service “class” that should be matched. If the value is not specified and there is more than one matching service registered, an error is returned.
deployment_target (str) – The deployment target from which the service should be resolved. Callers should pass either the url string from a
ComputeNodeSpecifieror a blank string for local execution.version (str) – The version of the service to resolve. If not specified, the latest version will be resolved.
- Returns:
A tuple containing the service location and service information.
- Return type:
tuple[ni.measurementlink.discovery.v1.client._types.ServiceLocation, ni.measurementlink.discovery.v1.client._types.ServiceInfo]
- enumerate_services(provided_interface)[source]
Enumerates all the services for the provided interface.
- Parameters:
provided_interface (str) – The gRPC full name of the services.
- Returns:
The list of information describing the services.
- Return type:
collections.abc.Sequence[ni.measurementlink.discovery.v1.client._types.ServiceInfo]
- enumerate_compute_nodes()[source]
Enumerates all the compute nodes registered with the discovery service.
- Returns:
The list of information describing the compute nodes.
- Return type:
collections.abc.Sequence[ni.measurementlink.discovery.v1.client._types.ComputeNodeDescriptor]
- class ni.measurementlink.discovery.v1.client.ComputeNodeDescriptor[source]
Bases:
NamedTupleRepresents a compute node.
- class ni.measurementlink.discovery.v1.client.ServiceInfo[source]
Bases:
NamedTupleA named tuple providing information about a registered service.
This class is used with the NI Discovery Service when registering and enumerating services.
- service_class: str
“The “class” of a service. The value of this field should be unique for all services. In effect, the
.protoservice declaration defines the interface, and this field defines a class or concrete type of the interface.
- provided_interfaces: list[str] = ['ni.measurementlink.measurement.v1.MeasurementService']
The service interfaces provided by the service. These are gRPC full names for the service.
- annotations: dict[str, str]
Represents a set of annotations on the service.
Well-known annotations:
- Description
- Key: “ni/service.description”
Expected format: string
Example: “Measure inrush current with a shorted load and validate results against configured limits.”
- Collection
- Key: “ni/service.collection”
Expected format: “.” delimited namespace/hierarchy case-insensitive string
Example: “CurrentTests.Inrush”
- Tags
- Key: “ni/service.tags”
Expected format: serialized JSON string of an array of strings
Example: “[“powerup”, “current”]”