no_endpoints.go raw
1 package endpoints
2
3 import (
4 "context"
5
6 "google.golang.org/grpc"
7 "google.golang.org/protobuf/reflect/protoreflect"
8
9 "github.com/yandex-cloud/go-sdk/v2/pkg/errors"
10 )
11
12 // NoEndpointsResolver returns an EndpointsResolver that always fails to resolve endpoints with a not found error.
13 func NoEndpointsResolver() EndpointsResolver { return noEndpointsResolver{} }
14
15 // noEndpointsResolver is a type implementing the EndpointsResolver interface that always returns EndpointNotFoundError.
16 type noEndpointsResolver struct{}
17
18 func (noEndpointsResolver) Endpoint(ctx context.Context, method protoreflect.FullName, opts ...grpc.CallOption) (*Endpoint, error) {
19 return nil, &errors.EndpointNotFoundError{Method: method}
20 }
21