| 1 |
// Copyright The OpenTelemetry Authors |
| 2 |
// SPDX-License-Identifier: Apache-2.0 |
| 3 |
|
| 4 |
package otelgrpc // import "go.opentelemetry.io/collector/pdata/internal/otelgrpc" |
| 5 |
|
| 6 |
import ( |
| 7 |
"context" |
| 8 |
|
| 9 |
"google.golang.org/grpc" |
| 10 |
"google.golang.org/grpc/codes" |
| 11 |
"google.golang.org/grpc/status" |
| 12 |
|
| 13 |
"go.opentelemetry.io/collector/pdata/internal" |
| 14 |
) |
| 15 |
|
| 16 |
// ProfilesServiceClient is the client API for ProfilesService service. |
| 17 |
// |
| 18 |
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. |
| 19 |
type ProfilesServiceClient interface { |
| 20 |
Export(context.Context, *internal.ExportProfilesServiceRequest, ...grpc.CallOption) (*internal.ExportProfilesServiceResponse, error) |
| 21 |
} |
| 22 |
|
| 23 |
type profilesServiceClient struct { |
| 24 |
cc *grpc.ClientConn |
| 25 |
} |
| 26 |
|
| 27 |
func NewProfilesServiceClient(cc *grpc.ClientConn) ProfilesServiceClient { |
| 28 |
return &profilesServiceClient{cc} |
| 29 |
} |
| 30 |
|
| 31 |
func (c *profilesServiceClient) Export(ctx context.Context, in *internal.ExportProfilesServiceRequest, opts ...grpc.CallOption) (*internal.ExportProfilesServiceResponse, error) { |
| 32 |
out := new(internal.ExportProfilesServiceResponse) |
| 33 |
err := c.cc.Invoke(ctx, "/opentelemetry.proto.collector.profiles.v1development.ProfilesService/Export", in, out, opts...) |
| 34 |
if err != nil { |
| 35 |
return nil, err |
| 36 |
} |
| 37 |
return out, nil |
| 38 |
} |
| 39 |
|
| 40 |
// ProfilesServiceServer is the server API for ProfilesService service. |
| 41 |
type ProfilesServiceServer interface { |
| 42 |
Export(context.Context, *internal.ExportProfilesServiceRequest) (*internal.ExportProfilesServiceResponse, error) |
| 43 |
} |
| 44 |
|
| 45 |
// UnimplementedProfilesServiceServer can be embedded to have forward compatible implementations. |
| 46 |
type UnimplementedProfilesServiceServer struct{} |
| 47 |
|
| 48 |
func (*UnimplementedProfilesServiceServer) Export(context.Context, *internal.ExportProfilesServiceRequest) (*internal.ExportProfilesServiceResponse, error) { |
| 49 |
return nil, status.Errorf(codes.Unimplemented, "method Export not implemented") |
| 50 |
} |
| 51 |
|
| 52 |
func RegisterProfilesServiceServer(s *grpc.Server, srv ProfilesServiceServer) { |
| 53 |
s.RegisterService(&profilesServiceServiceDesc, srv) |
| 54 |
} |
| 55 |
|
| 56 |
// Context cannot be the first parameter of the function because gRPC definition. |
| 57 |
// |
| 58 |
//nolint:revive |
| 59 |
func profilesServiceExportHandler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { |
| 60 |
in := new(internal.ExportProfilesServiceRequest) |
| 61 |
if err := dec(in); err != nil { |
| 62 |
return nil, err |
| 63 |
} |
| 64 |
if interceptor == nil { |
| 65 |
return srv.(ProfilesServiceServer).Export(ctx, in) |
| 66 |
} |
| 67 |
info := &grpc.UnaryServerInfo{ |
| 68 |
Server: srv, |
| 69 |
FullMethod: "/opentelemetry.proto.collector.profiles.v1development.ProfilesService/Export", |
| 70 |
} |
| 71 |
handler := func(ctx context.Context, req any) (any, error) { |
| 72 |
return srv.(ProfilesServiceServer).Export(ctx, req.(*internal.ExportProfilesServiceRequest)) |
| 73 |
} |
| 74 |
return interceptor(ctx, in, info, handler) |
| 75 |
} |
| 76 |
|
| 77 |
var profilesServiceServiceDesc = grpc.ServiceDesc{ |
| 78 |
ServiceName: "opentelemetry.proto.collector.profiles.v1development.ProfilesService", |
| 79 |
HandlerType: (*ProfilesServiceServer)(nil), |
| 80 |
Methods: []grpc.MethodDesc{ |
| 81 |
{ |
| 82 |
MethodName: "Export", |
| 83 |
Handler: profilesServiceExportHandler, |
| 84 |
}, |
| 85 |
}, |
| 86 |
Streams: []grpc.StreamDesc{}, |
| 87 |
Metadata: "opentelemetry/proto/collector/profiles/v1development/profiles_service.proto", |
| 88 |
} |