github.com/NpoolPlatform/chain-middleware@v0.0.0-20240228100535-eb1bcf896eb9/api/coin/currency/feed/query.go (about) 1 package currencyfeed 2 3 import ( 4 "context" 5 6 currencyfeed1 "github.com/NpoolPlatform/chain-middleware/pkg/mw/coin/currency/feed" 7 "github.com/NpoolPlatform/go-service-framework/pkg/logger" 8 npool "github.com/NpoolPlatform/message/npool/chain/mw/v1/coin/currency/feed" 9 10 "google.golang.org/grpc/codes" 11 "google.golang.org/grpc/status" 12 ) 13 14 func (s *Server) GetFeeds(ctx context.Context, in *npool.GetFeedsRequest) (*npool.GetFeedsResponse, error) { 15 handler, err := currencyfeed1.NewHandler( 16 ctx, 17 currencyfeed1.WithConds(in.Conds), 18 currencyfeed1.WithOffset(in.GetOffset()), 19 currencyfeed1.WithLimit(in.GetLimit()), 20 ) 21 if err != nil { 22 logger.Sugar().Errorw( 23 "GetFeeds", 24 "In", in, 25 "Error", err, 26 ) 27 return &npool.GetFeedsResponse{}, status.Error(codes.InvalidArgument, err.Error()) 28 } 29 30 infos, total, err := handler.GetFeeds(ctx) 31 if err != nil { 32 logger.Sugar().Errorw( 33 "GetFeeds", 34 "In", in, 35 "Error", err, 36 ) 37 return &npool.GetFeedsResponse{}, status.Error(codes.Internal, err.Error()) 38 } 39 40 return &npool.GetFeedsResponse{ 41 Infos: infos, 42 Total: total, 43 }, nil 44 }