Documentation ¶
Index ¶
- func BidFlow(s *Server, req *rpc.BidProductRequest) error
- func BuyProductFlow(s *Server, req *rpc.PayOffRequest) error
- func CloseProductFlow(s *Server, req *rpc.CloseProductRequest) error
- func CreateProductFlow(s *Server, req *rpc.CreateProductRequest) error
- func NewTimer(d time.Duration, fn func()) *time.Timer
- func StartServer(cfg *config.Config) chan struct{}
- type Server
- func (s *Server) AuthUser(ctx context.Context, in *rpc.AuthUserRequest) (*rpc.AuthUserResponse, error)
- func (s *Server) BidProduct(ctx context.Context, in *rpc.BidProductRequest) (*rpc.BidProductResponse, error)
- func (s *Server) CheckOrCreateUser(ctx context.Context, req *rpc.CheckOrCreateUserRequest) (*rpc.CheckOrCreateUserResponse, error)
- func (s *Server) CloseProduct(ctx context.Context, in *rpc.CloseProductRequest) (*rpc.CloseProductResponse, error)
- func (s *Server) CreateBidder(ctx context.Context, in *rpc.CreateBidderRequest) (*rpc.CreateBidderResponse, error)
- func (s *Server) CreateProduct(ctx context.Context, req *rpc.CreateProductRequest) (*rpc.CreateProductResponse, error)
- func (s *Server) CreateUser(ctx context.Context, in *rpc.CreateUserRequest) (*rpc.CreateUserResponse, error)
- func (s *Server) DeleteUser(ctx context.Context, in *rpc.DeleteUserRequest) (*rpc.DeleteUserResponse, error)
- func (s *Server) GetBidder(ctx context.Context, in *rpc.GetBidderRequest) (*rpc.GetBidderResponse, error)
- func (s *Server) GetProduct(ctx context.Context, req *rpc.GetProductRequest) (*rpc.GetProductResponse, error)
- func (s *Server) GetProducts(ctx context.Context, in *rpc.GetProductsRequest) (*rpc.GetProductsResponse, error)
- func (s *Server) GetUser(ctx context.Context, in *rpc.GetUserRequest) (*rpc.GetUserResponse, error)
- func (s *Server) PayOff(ctx context.Context, in *rpc.PayOffRequest) (*rpc.PayOffResponse, error)
- func (s *Server) TestingDropAll(ctx context.Context, in *rpc.TestingDropRequest) (*rpc.TestingDropResponse, error)
- func (s *Server) UpdateBidder(ctx context.Context, in *rpc.UpdateBidderRequest) (*rpc.UpdateBidderResponse, error)
- func (s *Server) UpdateProduct(ctx context.Context, in *rpc.UpdateProductRequest) (*rpc.UpdateProductResponse, error)
- func (s *Server) UpdateUser(ctx context.Context, in *rpc.UpdateUserRequest) (*rpc.UpdateUserResponse, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BidFlow ¶
func BidFlow(s *Server, req *rpc.BidProductRequest) error
Bid flow (done)
1. Create a bid object with bid ID, user ID, product ID. 2. If this is the first bid from the user, charge the deposit. 3. Update the product with new lowest price and Bid ID.
func BuyProductFlow ¶
func BuyProductFlow(s *Server, req *rpc.PayOffRequest) error
Buy product flow (done)
1. Update the product to deal, final price and everything. 2. Return buyer's deposit and charge buyer based on final price. 3. Update the bidder for offline action.
func CloseProductFlow ¶
func CloseProductFlow(s *Server, req *rpc.CloseProductRequest) error
Close product flow (done)
1. Close product to status close 2. Transfer money to bidder's account
func CreateProductFlow ¶
func CreateProductFlow(s *Server, req *rpc.CreateProductRequest) error
Create product flow (done)
1. Create a product with product ID, user ID. 2. Add the product expiration time and add a call back to buy transaction at Scheduler. 3. Charge buyer's deposit
func StartServer ¶
Types ¶
type Server ¶
type Server struct { Config *config.Config Auth *auth.AuthModule Mongo *db.MongoConnection ProductIdToTimerMap map[int64]*time.Timer // Persistent state MywishAccount string // contains filtered or unexported fields }
func (*Server) AuthUser ¶
func (s *Server) AuthUser(ctx context.Context, in *rpc.AuthUserRequest) (*rpc.AuthUserResponse, error)
func (*Server) BidProduct ¶
func (s *Server) BidProduct(ctx context.Context, in *rpc.BidProductRequest) (*rpc.BidProductResponse, error)
func (*Server) CheckOrCreateUser ¶
func (s *Server) CheckOrCreateUser(ctx context.Context, req *rpc.CheckOrCreateUserRequest) (*rpc.CheckOrCreateUserResponse, error)
func (*Server) CloseProduct ¶
func (s *Server) CloseProduct(ctx context.Context, in *rpc.CloseProductRequest) (*rpc.CloseProductResponse, error)
func (*Server) CreateBidder ¶
func (s *Server) CreateBidder(ctx context.Context, in *rpc.CreateBidderRequest) (*rpc.CreateBidderResponse, error)
func (*Server) CreateProduct ¶
func (s *Server) CreateProduct(ctx context.Context, req *rpc.CreateProductRequest) (*rpc.CreateProductResponse, error)
func (*Server) CreateUser ¶
func (s *Server) CreateUser(ctx context.Context, in *rpc.CreateUserRequest) (*rpc.CreateUserResponse, error)
func (*Server) DeleteUser ¶
func (s *Server) DeleteUser(ctx context.Context, in *rpc.DeleteUserRequest) (*rpc.DeleteUserResponse, error)
func (*Server) GetBidder ¶
func (s *Server) GetBidder(ctx context.Context, in *rpc.GetBidderRequest) (*rpc.GetBidderResponse, error)
func (*Server) GetProduct ¶
func (s *Server) GetProduct(ctx context.Context, req *rpc.GetProductRequest) (*rpc.GetProductResponse, error)
func (*Server) GetProducts ¶
func (s *Server) GetProducts(ctx context.Context, in *rpc.GetProductsRequest) (*rpc.GetProductsResponse, error)
func (*Server) GetUser ¶
func (s *Server) GetUser(ctx context.Context, in *rpc.GetUserRequest) (*rpc.GetUserResponse, error)
func (*Server) PayOff ¶
func (s *Server) PayOff(ctx context.Context, in *rpc.PayOffRequest) (*rpc.PayOffResponse, error)
func (*Server) TestingDropAll ¶
func (s *Server) TestingDropAll(ctx context.Context, in *rpc.TestingDropRequest) (*rpc.TestingDropResponse, error)
func (*Server) UpdateBidder ¶
func (s *Server) UpdateBidder(ctx context.Context, in *rpc.UpdateBidderRequest) (*rpc.UpdateBidderResponse, error)
func (*Server) UpdateProduct ¶
func (s *Server) UpdateProduct(ctx context.Context, in *rpc.UpdateProductRequest) (*rpc.UpdateProductResponse, error)
func (*Server) UpdateUser ¶
func (s *Server) UpdateUser(ctx context.Context, in *rpc.UpdateUserRequest) (*rpc.UpdateUserResponse, error)
Click to show internal directories.
Click to hide internal directories.