server

package
v0.0.0-...-704c986 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 28, 2018 License: MIT Imports: 27 Imported by: 0

Documentation

Index

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 NewTimer

func NewTimer(d time.Duration, fn func()) *time.Timer

func StartServer

func StartServer(cfg *config.Config) chan struct{}

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 NewServer

func NewServer(cfg *config.Config) (*Server, error)

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 (*Server) CloseProduct

func (*Server) CreateBidder

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 (*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 (*Server) UpdateProduct

func (*Server) UpdateUser

func (s *Server) UpdateUser(ctx context.Context, in *rpc.UpdateUserRequest) (*rpc.UpdateUserResponse, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL