You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
go-zero/internal/mock/depositserver.go

23 lines
543 B
Go

4 years ago
package mock
import (
"context"
"time"
4 years ago
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
4 years ago
// DepositServer is used for mocking.
type DepositServer struct{}
4 years ago
// Deposit handles the deposit requests.
4 years ago
func (*DepositServer) Deposit(ctx context.Context, req *DepositRequest) (*DepositResponse, error) {
if req.GetAmount() < 0 {
return nil, status.Errorf(codes.InvalidArgument, "cannot deposit %v", req.GetAmount())
}
time.Sleep(time.Duration(req.GetAmount()) * time.Millisecond)
4 years ago
return &DepositResponse{Ok: true}, nil
}