handler.go 830 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package handler
  2. import (
  3. "bet24.com/log"
  4. pb "bet24.com/servers/micros/money/proto"
  5. "context"
  6. "fmt"
  7. )
  8. var instance *Money
  9. type Money struct {
  10. }
  11. func newHandler() *Money {
  12. ret := new(Money)
  13. ret.ctor()
  14. return ret
  15. }
  16. func (g *Money) ctor() {
  17. RunCash()
  18. RunChip()
  19. }
  20. func GetInstance() *Money {
  21. if instance == nil {
  22. instance = newHandler()
  23. }
  24. return instance
  25. }
  26. func Dump(cmd, param1, param2 string) {
  27. GetInstance().dump(cmd, param1, param2)
  28. }
  29. func (this *Money) dump(cmd, param1, param2 string) {
  30. switch cmd {
  31. case "transfer":
  32. getTransferManager().dump(param1, param2)
  33. default:
  34. log.Release("Money.Dump unhandled cmd %s", cmd)
  35. }
  36. }
  37. func (this *Money) SayHello(ctx context.Context, req *pb.Request, rsp *pb.Response) error {
  38. rsp.Data = fmt.Sprintf("Hello from %s:%s", pb.ServiceName, req.Name)
  39. return nil
  40. }