handler.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package handler
  2. import (
  3. "bet24.com/log"
  4. "bet24.com/servers/micros/highly_profitable/handler/highly_profitable"
  5. pb "bet24.com/servers/micros/highly_profitable/proto"
  6. "context"
  7. "fmt"
  8. )
  9. var instance *highlyProfitableService
  10. type highlyProfitableService struct {
  11. }
  12. func GetInstance() *highlyProfitableService {
  13. if instance == nil {
  14. instance = newHandler()
  15. }
  16. return instance
  17. }
  18. func newHandler() *highlyProfitableService {
  19. ret := new(highlyProfitableService)
  20. ret.ctor()
  21. return ret
  22. }
  23. func (h *highlyProfitableService) ctor() {
  24. highly_profitable.Run()
  25. }
  26. func Dump(cmd, param1, param2 string) {
  27. GetInstance().dump(cmd, param1, param2)
  28. }
  29. func (h *highlyProfitableService) dump(cmd, param1, param2 string) {
  30. switch cmd {
  31. case "highly_profitable":
  32. highly_profitable.Dump(param1, param2)
  33. default:
  34. log.Release("highlyProfitableService.Dump unhandled cmd %s", cmd)
  35. }
  36. }
  37. func (h *highlyProfitableService) 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. }