mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-01-24 01:30:25 +08:00
cb8d9d413a
Co-authored-by: chenmusheng <chenmusheng@laoyuegou.com>
23 lines
543 B
Go
23 lines
543 B
Go
package mock
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"google.golang.org/grpc/codes"
|
|
"google.golang.org/grpc/status"
|
|
)
|
|
|
|
// DepositServer is used for mocking.
|
|
type DepositServer struct{}
|
|
|
|
// Deposit handles the deposit requests.
|
|
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)
|
|
return &DepositResponse{Ok: true}, nil
|
|
}
|