gateway: open timeout function cabinet (#3047)
Co-authored-by: Kevin Wan <wanjunfeng@gmail.com>
This commit is contained in:
22
internal/mock/depositserver.go
Normal file
22
internal/mock/depositserver.go
Normal file
@@ -0,0 +1,22 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user