401 lines
15 KiB
Go
401 lines
15 KiB
Go
// Code generated by internal/gen/api/main.go. DO NOT EDIT.
|
|
|
|
package api
|
|
|
|
import (
|
|
"context"
|
|
|
|
. "github.com/centrifugal/centrifugo/v6/internal/apiproto"
|
|
"github.com/centrifugal/centrifugo/v6/internal/metrics"
|
|
|
|
"go.opentelemetry.io/otel/codes"
|
|
"go.opentelemetry.io/otel/trace"
|
|
"google.golang.org/grpc/status"
|
|
)
|
|
|
|
// Batch ...
|
|
func (s *grpcAPIService) Batch(ctx context.Context, req *BatchRequest) (*BatchResponse, error) {
|
|
resp := s.api.Batch(ctx, req)
|
|
return resp, nil
|
|
}
|
|
|
|
// Publish ...
|
|
func (s *grpcAPIService) Publish(ctx context.Context, req *PublishRequest) (*PublishResponse, error) {
|
|
resp := s.api.Publish(ctx, req)
|
|
if s.config.UseOpenTelemetry && resp.Error != nil {
|
|
span := trace.SpanFromContext(ctx)
|
|
span.SetStatus(codes.Error, resp.Error.Error())
|
|
}
|
|
if resp.Error != nil && s.useTransportErrorMode(ctx) {
|
|
metrics.IncAPIError(s.api.config.Protocol, "publish", resp.Error.Code)
|
|
statusCode := MapErrorToGRPCCode(resp.Error)
|
|
transportError, _ := status.New(statusCode, resp.Error.Message).WithDetails(resp.Error)
|
|
return nil, transportError.Err()
|
|
}
|
|
if resp.Error != nil {
|
|
metrics.IncAPIError(s.api.config.Protocol, "publish", resp.Error.Code)
|
|
}
|
|
return resp, nil
|
|
}
|
|
|
|
// Broadcast ...
|
|
func (s *grpcAPIService) Broadcast(ctx context.Context, req *BroadcastRequest) (*BroadcastResponse, error) {
|
|
resp := s.api.Broadcast(ctx, req)
|
|
if s.config.UseOpenTelemetry && resp.Error != nil {
|
|
span := trace.SpanFromContext(ctx)
|
|
span.SetStatus(codes.Error, resp.Error.Error())
|
|
}
|
|
if resp.Error != nil && s.useTransportErrorMode(ctx) {
|
|
metrics.IncAPIError(s.api.config.Protocol, "broadcast", resp.Error.Code)
|
|
statusCode := MapErrorToGRPCCode(resp.Error)
|
|
transportError, _ := status.New(statusCode, resp.Error.Message).WithDetails(resp.Error)
|
|
return nil, transportError.Err()
|
|
}
|
|
if resp.Error != nil {
|
|
metrics.IncAPIError(s.api.config.Protocol, "broadcast", resp.Error.Code)
|
|
}
|
|
return resp, nil
|
|
}
|
|
|
|
// Subscribe ...
|
|
func (s *grpcAPIService) Subscribe(ctx context.Context, req *SubscribeRequest) (*SubscribeResponse, error) {
|
|
resp := s.api.Subscribe(ctx, req)
|
|
if s.config.UseOpenTelemetry && resp.Error != nil {
|
|
span := trace.SpanFromContext(ctx)
|
|
span.SetStatus(codes.Error, resp.Error.Error())
|
|
}
|
|
if resp.Error != nil && s.useTransportErrorMode(ctx) {
|
|
metrics.IncAPIError(s.api.config.Protocol, "subscribe", resp.Error.Code)
|
|
statusCode := MapErrorToGRPCCode(resp.Error)
|
|
transportError, _ := status.New(statusCode, resp.Error.Message).WithDetails(resp.Error)
|
|
return nil, transportError.Err()
|
|
}
|
|
if resp.Error != nil {
|
|
metrics.IncAPIError(s.api.config.Protocol, "subscribe", resp.Error.Code)
|
|
}
|
|
return resp, nil
|
|
}
|
|
|
|
// Unsubscribe ...
|
|
func (s *grpcAPIService) Unsubscribe(ctx context.Context, req *UnsubscribeRequest) (*UnsubscribeResponse, error) {
|
|
resp := s.api.Unsubscribe(ctx, req)
|
|
if s.config.UseOpenTelemetry && resp.Error != nil {
|
|
span := trace.SpanFromContext(ctx)
|
|
span.SetStatus(codes.Error, resp.Error.Error())
|
|
}
|
|
if resp.Error != nil && s.useTransportErrorMode(ctx) {
|
|
metrics.IncAPIError(s.api.config.Protocol, "unsubscribe", resp.Error.Code)
|
|
statusCode := MapErrorToGRPCCode(resp.Error)
|
|
transportError, _ := status.New(statusCode, resp.Error.Message).WithDetails(resp.Error)
|
|
return nil, transportError.Err()
|
|
}
|
|
if resp.Error != nil {
|
|
metrics.IncAPIError(s.api.config.Protocol, "unsubscribe", resp.Error.Code)
|
|
}
|
|
return resp, nil
|
|
}
|
|
|
|
// Disconnect ...
|
|
func (s *grpcAPIService) Disconnect(ctx context.Context, req *DisconnectRequest) (*DisconnectResponse, error) {
|
|
resp := s.api.Disconnect(ctx, req)
|
|
if s.config.UseOpenTelemetry && resp.Error != nil {
|
|
span := trace.SpanFromContext(ctx)
|
|
span.SetStatus(codes.Error, resp.Error.Error())
|
|
}
|
|
if resp.Error != nil && s.useTransportErrorMode(ctx) {
|
|
metrics.IncAPIError(s.api.config.Protocol, "disconnect", resp.Error.Code)
|
|
statusCode := MapErrorToGRPCCode(resp.Error)
|
|
transportError, _ := status.New(statusCode, resp.Error.Message).WithDetails(resp.Error)
|
|
return nil, transportError.Err()
|
|
}
|
|
if resp.Error != nil {
|
|
metrics.IncAPIError(s.api.config.Protocol, "disconnect", resp.Error.Code)
|
|
}
|
|
return resp, nil
|
|
}
|
|
|
|
// Presence ...
|
|
func (s *grpcAPIService) Presence(ctx context.Context, req *PresenceRequest) (*PresenceResponse, error) {
|
|
resp := s.api.Presence(ctx, req)
|
|
if s.config.UseOpenTelemetry && resp.Error != nil {
|
|
span := trace.SpanFromContext(ctx)
|
|
span.SetStatus(codes.Error, resp.Error.Error())
|
|
}
|
|
if resp.Error != nil && s.useTransportErrorMode(ctx) {
|
|
metrics.IncAPIError(s.api.config.Protocol, "presence", resp.Error.Code)
|
|
statusCode := MapErrorToGRPCCode(resp.Error)
|
|
transportError, _ := status.New(statusCode, resp.Error.Message).WithDetails(resp.Error)
|
|
return nil, transportError.Err()
|
|
}
|
|
if resp.Error != nil {
|
|
metrics.IncAPIError(s.api.config.Protocol, "presence", resp.Error.Code)
|
|
}
|
|
return resp, nil
|
|
}
|
|
|
|
// PresenceStats ...
|
|
func (s *grpcAPIService) PresenceStats(ctx context.Context, req *PresenceStatsRequest) (*PresenceStatsResponse, error) {
|
|
resp := s.api.PresenceStats(ctx, req)
|
|
if s.config.UseOpenTelemetry && resp.Error != nil {
|
|
span := trace.SpanFromContext(ctx)
|
|
span.SetStatus(codes.Error, resp.Error.Error())
|
|
}
|
|
if resp.Error != nil && s.useTransportErrorMode(ctx) {
|
|
metrics.IncAPIError(s.api.config.Protocol, "presence_stats", resp.Error.Code)
|
|
statusCode := MapErrorToGRPCCode(resp.Error)
|
|
transportError, _ := status.New(statusCode, resp.Error.Message).WithDetails(resp.Error)
|
|
return nil, transportError.Err()
|
|
}
|
|
if resp.Error != nil {
|
|
metrics.IncAPIError(s.api.config.Protocol, "presence_stats", resp.Error.Code)
|
|
}
|
|
return resp, nil
|
|
}
|
|
|
|
// History ...
|
|
func (s *grpcAPIService) History(ctx context.Context, req *HistoryRequest) (*HistoryResponse, error) {
|
|
resp := s.api.History(ctx, req)
|
|
if s.config.UseOpenTelemetry && resp.Error != nil {
|
|
span := trace.SpanFromContext(ctx)
|
|
span.SetStatus(codes.Error, resp.Error.Error())
|
|
}
|
|
if resp.Error != nil && s.useTransportErrorMode(ctx) {
|
|
metrics.IncAPIError(s.api.config.Protocol, "history", resp.Error.Code)
|
|
statusCode := MapErrorToGRPCCode(resp.Error)
|
|
transportError, _ := status.New(statusCode, resp.Error.Message).WithDetails(resp.Error)
|
|
return nil, transportError.Err()
|
|
}
|
|
if resp.Error != nil {
|
|
metrics.IncAPIError(s.api.config.Protocol, "history", resp.Error.Code)
|
|
}
|
|
return resp, nil
|
|
}
|
|
|
|
// HistoryRemove ...
|
|
func (s *grpcAPIService) HistoryRemove(ctx context.Context, req *HistoryRemoveRequest) (*HistoryRemoveResponse, error) {
|
|
resp := s.api.HistoryRemove(ctx, req)
|
|
if s.config.UseOpenTelemetry && resp.Error != nil {
|
|
span := trace.SpanFromContext(ctx)
|
|
span.SetStatus(codes.Error, resp.Error.Error())
|
|
}
|
|
if resp.Error != nil && s.useTransportErrorMode(ctx) {
|
|
metrics.IncAPIError(s.api.config.Protocol, "history_remove", resp.Error.Code)
|
|
statusCode := MapErrorToGRPCCode(resp.Error)
|
|
transportError, _ := status.New(statusCode, resp.Error.Message).WithDetails(resp.Error)
|
|
return nil, transportError.Err()
|
|
}
|
|
if resp.Error != nil {
|
|
metrics.IncAPIError(s.api.config.Protocol, "history_remove", resp.Error.Code)
|
|
}
|
|
return resp, nil
|
|
}
|
|
|
|
// Info ...
|
|
func (s *grpcAPIService) Info(ctx context.Context, req *InfoRequest) (*InfoResponse, error) {
|
|
resp := s.api.Info(ctx, req)
|
|
if s.config.UseOpenTelemetry && resp.Error != nil {
|
|
span := trace.SpanFromContext(ctx)
|
|
span.SetStatus(codes.Error, resp.Error.Error())
|
|
}
|
|
if resp.Error != nil && s.useTransportErrorMode(ctx) {
|
|
metrics.IncAPIError(s.api.config.Protocol, "info", resp.Error.Code)
|
|
statusCode := MapErrorToGRPCCode(resp.Error)
|
|
transportError, _ := status.New(statusCode, resp.Error.Message).WithDetails(resp.Error)
|
|
return nil, transportError.Err()
|
|
}
|
|
if resp.Error != nil {
|
|
metrics.IncAPIError(s.api.config.Protocol, "info", resp.Error.Code)
|
|
}
|
|
return resp, nil
|
|
}
|
|
|
|
// RPC ...
|
|
func (s *grpcAPIService) RPC(ctx context.Context, req *RPCRequest) (*RPCResponse, error) {
|
|
resp := s.api.RPC(ctx, req)
|
|
if s.config.UseOpenTelemetry && resp.Error != nil {
|
|
span := trace.SpanFromContext(ctx)
|
|
span.SetStatus(codes.Error, resp.Error.Error())
|
|
}
|
|
if resp.Error != nil && s.useTransportErrorMode(ctx) {
|
|
metrics.IncAPIError(s.api.config.Protocol, "rpc", resp.Error.Code)
|
|
statusCode := MapErrorToGRPCCode(resp.Error)
|
|
transportError, _ := status.New(statusCode, resp.Error.Message).WithDetails(resp.Error)
|
|
return nil, transportError.Err()
|
|
}
|
|
if resp.Error != nil {
|
|
metrics.IncAPIError(s.api.config.Protocol, "rpc", resp.Error.Code)
|
|
}
|
|
return resp, nil
|
|
}
|
|
|
|
// Refresh ...
|
|
func (s *grpcAPIService) Refresh(ctx context.Context, req *RefreshRequest) (*RefreshResponse, error) {
|
|
resp := s.api.Refresh(ctx, req)
|
|
if s.config.UseOpenTelemetry && resp.Error != nil {
|
|
span := trace.SpanFromContext(ctx)
|
|
span.SetStatus(codes.Error, resp.Error.Error())
|
|
}
|
|
if resp.Error != nil && s.useTransportErrorMode(ctx) {
|
|
metrics.IncAPIError(s.api.config.Protocol, "refresh", resp.Error.Code)
|
|
statusCode := MapErrorToGRPCCode(resp.Error)
|
|
transportError, _ := status.New(statusCode, resp.Error.Message).WithDetails(resp.Error)
|
|
return nil, transportError.Err()
|
|
}
|
|
if resp.Error != nil {
|
|
metrics.IncAPIError(s.api.config.Protocol, "refresh", resp.Error.Code)
|
|
}
|
|
return resp, nil
|
|
}
|
|
|
|
// Channels ...
|
|
func (s *grpcAPIService) Channels(ctx context.Context, req *ChannelsRequest) (*ChannelsResponse, error) {
|
|
resp := s.api.Channels(ctx, req)
|
|
if s.config.UseOpenTelemetry && resp.Error != nil {
|
|
span := trace.SpanFromContext(ctx)
|
|
span.SetStatus(codes.Error, resp.Error.Error())
|
|
}
|
|
if resp.Error != nil && s.useTransportErrorMode(ctx) {
|
|
metrics.IncAPIError(s.api.config.Protocol, "channels", resp.Error.Code)
|
|
statusCode := MapErrorToGRPCCode(resp.Error)
|
|
transportError, _ := status.New(statusCode, resp.Error.Message).WithDetails(resp.Error)
|
|
return nil, transportError.Err()
|
|
}
|
|
if resp.Error != nil {
|
|
metrics.IncAPIError(s.api.config.Protocol, "channels", resp.Error.Code)
|
|
}
|
|
return resp, nil
|
|
}
|
|
|
|
// MapPublish ...
|
|
func (s *grpcAPIService) MapPublish(ctx context.Context, req *MapPublishRequest) (*MapPublishResponse, error) {
|
|
resp := s.api.MapPublish(ctx, req)
|
|
if s.config.UseOpenTelemetry && resp.Error != nil {
|
|
span := trace.SpanFromContext(ctx)
|
|
span.SetStatus(codes.Error, resp.Error.Error())
|
|
}
|
|
if resp.Error != nil && s.useTransportErrorMode(ctx) {
|
|
metrics.IncAPIError(s.api.config.Protocol, "map_publish", resp.Error.Code)
|
|
statusCode := MapErrorToGRPCCode(resp.Error)
|
|
transportError, _ := status.New(statusCode, resp.Error.Message).WithDetails(resp.Error)
|
|
return nil, transportError.Err()
|
|
}
|
|
if resp.Error != nil {
|
|
metrics.IncAPIError(s.api.config.Protocol, "map_publish", resp.Error.Code)
|
|
}
|
|
return resp, nil
|
|
}
|
|
|
|
// MapRemove ...
|
|
func (s *grpcAPIService) MapRemove(ctx context.Context, req *MapRemoveRequest) (*MapRemoveResponse, error) {
|
|
resp := s.api.MapRemove(ctx, req)
|
|
if s.config.UseOpenTelemetry && resp.Error != nil {
|
|
span := trace.SpanFromContext(ctx)
|
|
span.SetStatus(codes.Error, resp.Error.Error())
|
|
}
|
|
if resp.Error != nil && s.useTransportErrorMode(ctx) {
|
|
metrics.IncAPIError(s.api.config.Protocol, "map_remove", resp.Error.Code)
|
|
statusCode := MapErrorToGRPCCode(resp.Error)
|
|
transportError, _ := status.New(statusCode, resp.Error.Message).WithDetails(resp.Error)
|
|
return nil, transportError.Err()
|
|
}
|
|
if resp.Error != nil {
|
|
metrics.IncAPIError(s.api.config.Protocol, "map_remove", resp.Error.Code)
|
|
}
|
|
return resp, nil
|
|
}
|
|
|
|
// MapReadState ...
|
|
func (s *grpcAPIService) MapReadState(ctx context.Context, req *MapReadStateRequest) (*MapReadStateResponse, error) {
|
|
resp := s.api.MapReadState(ctx, req)
|
|
if s.config.UseOpenTelemetry && resp.Error != nil {
|
|
span := trace.SpanFromContext(ctx)
|
|
span.SetStatus(codes.Error, resp.Error.Error())
|
|
}
|
|
if resp.Error != nil && s.useTransportErrorMode(ctx) {
|
|
metrics.IncAPIError(s.api.config.Protocol, "map_read_state", resp.Error.Code)
|
|
statusCode := MapErrorToGRPCCode(resp.Error)
|
|
transportError, _ := status.New(statusCode, resp.Error.Message).WithDetails(resp.Error)
|
|
return nil, transportError.Err()
|
|
}
|
|
if resp.Error != nil {
|
|
metrics.IncAPIError(s.api.config.Protocol, "map_read_state", resp.Error.Code)
|
|
}
|
|
return resp, nil
|
|
}
|
|
|
|
// MapReadStream ...
|
|
func (s *grpcAPIService) MapReadStream(ctx context.Context, req *MapReadStreamRequest) (*MapReadStreamResponse, error) {
|
|
resp := s.api.MapReadStream(ctx, req)
|
|
if s.config.UseOpenTelemetry && resp.Error != nil {
|
|
span := trace.SpanFromContext(ctx)
|
|
span.SetStatus(codes.Error, resp.Error.Error())
|
|
}
|
|
if resp.Error != nil && s.useTransportErrorMode(ctx) {
|
|
metrics.IncAPIError(s.api.config.Protocol, "map_read_stream", resp.Error.Code)
|
|
statusCode := MapErrorToGRPCCode(resp.Error)
|
|
transportError, _ := status.New(statusCode, resp.Error.Message).WithDetails(resp.Error)
|
|
return nil, transportError.Err()
|
|
}
|
|
if resp.Error != nil {
|
|
metrics.IncAPIError(s.api.config.Protocol, "map_read_stream", resp.Error.Code)
|
|
}
|
|
return resp, nil
|
|
}
|
|
|
|
// MapStats ...
|
|
func (s *grpcAPIService) MapStats(ctx context.Context, req *MapStatsRequest) (*MapStatsResponse, error) {
|
|
resp := s.api.MapStats(ctx, req)
|
|
if s.config.UseOpenTelemetry && resp.Error != nil {
|
|
span := trace.SpanFromContext(ctx)
|
|
span.SetStatus(codes.Error, resp.Error.Error())
|
|
}
|
|
if resp.Error != nil && s.useTransportErrorMode(ctx) {
|
|
metrics.IncAPIError(s.api.config.Protocol, "map_stats", resp.Error.Code)
|
|
statusCode := MapErrorToGRPCCode(resp.Error)
|
|
transportError, _ := status.New(statusCode, resp.Error.Message).WithDetails(resp.Error)
|
|
return nil, transportError.Err()
|
|
}
|
|
if resp.Error != nil {
|
|
metrics.IncAPIError(s.api.config.Protocol, "map_stats", resp.Error.Code)
|
|
}
|
|
return resp, nil
|
|
}
|
|
|
|
// MapClear ...
|
|
func (s *grpcAPIService) MapClear(ctx context.Context, req *MapClearRequest) (*MapClearResponse, error) {
|
|
resp := s.api.MapClear(ctx, req)
|
|
if s.config.UseOpenTelemetry && resp.Error != nil {
|
|
span := trace.SpanFromContext(ctx)
|
|
span.SetStatus(codes.Error, resp.Error.Error())
|
|
}
|
|
if resp.Error != nil && s.useTransportErrorMode(ctx) {
|
|
metrics.IncAPIError(s.api.config.Protocol, "map_clear", resp.Error.Code)
|
|
statusCode := MapErrorToGRPCCode(resp.Error)
|
|
transportError, _ := status.New(statusCode, resp.Error.Message).WithDetails(resp.Error)
|
|
return nil, transportError.Err()
|
|
}
|
|
if resp.Error != nil {
|
|
metrics.IncAPIError(s.api.config.Protocol, "map_clear", resp.Error.Code)
|
|
}
|
|
return resp, nil
|
|
}
|
|
|
|
// SharedPollPublish ...
|
|
func (s *grpcAPIService) SharedPollPublish(ctx context.Context, req *SharedPollPublishRequest) (*SharedPollPublishResponse, error) {
|
|
resp := s.api.SharedPollPublish(ctx, req)
|
|
if s.config.UseOpenTelemetry && resp.Error != nil {
|
|
span := trace.SpanFromContext(ctx)
|
|
span.SetStatus(codes.Error, resp.Error.Error())
|
|
}
|
|
if resp.Error != nil && s.useTransportErrorMode(ctx) {
|
|
metrics.IncAPIError(s.api.config.Protocol, "shared_poll_publish", resp.Error.Code)
|
|
statusCode := MapErrorToGRPCCode(resp.Error)
|
|
transportError, _ := status.New(statusCode, resp.Error.Message).WithDetails(resp.Error)
|
|
return nil, transportError.Err()
|
|
}
|
|
if resp.Error != nil {
|
|
metrics.IncAPIError(s.api.config.Protocol, "shared_poll_publish", resp.Error.Code)
|
|
}
|
|
return resp, nil
|
|
}
|