You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

main.go 2.3 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. package main
  2. import (
  3. //"context"
  4. //"io"
  5. "fmt"
  6. //"path/filepath"
  7. //"sync"
  8. "encoding/json"
  9. "rabbitmq"
  10. "time"
  11. //agentcaller "proto"
  12. //"github.com/pborman/uuid"
  13. //"github.com/streadway/amqp"
  14. //"google.golang.org/grpc"
  15. )
  16. func main() {
  17. rabbit := rabbitmq.NewRabbitMQSimple("coorQueue")
  18. msgs := rabbit.ConsumeSimpleQos(time.Millisecond * 500)
  19. forever := make(chan bool)
  20. // 启用协程处理消息
  21. go func() {
  22. for d := range msgs {
  23. // 实现我们要处理的逻辑函数
  24. b1 := d.Body
  25. commandType := string(b1[0:2])
  26. fmt.Println(commandType)
  27. c1 := b1[2:]
  28. switch commandType {
  29. case "00":
  30. var command rabbitmq.EcWriteCommand
  31. err := json.Unmarshal(c1, &command)
  32. if err != nil {
  33. fmt.Printf("json.Unmarshal failed, err:%v\n", err)
  34. }
  35. CoorEcWrite(command)
  36. case "01":
  37. var command rabbitmq.WriteHashCommand
  38. err := json.Unmarshal(c1, &command)
  39. if err != nil {
  40. fmt.Printf("json.Unmarshal failed, err:%v\n", err)
  41. }
  42. CoorEcWriteHash(command)
  43. case "02":
  44. var command rabbitmq.ReadCommand
  45. err := json.Unmarshal(c1, &command)
  46. if err != nil {
  47. fmt.Printf("json.Unmarshal failed, err:%v\n", err)
  48. }
  49. CoorRead(command)
  50. case "03":
  51. var command rabbitmq.RepWriteCommand
  52. err := json.Unmarshal(c1, &command)
  53. if err != nil {
  54. fmt.Printf("json.Unmarshal failed, err:%v\n", err)
  55. }
  56. CoorRepWrite(command)
  57. case "04":
  58. var command rabbitmq.WriteHashCommand
  59. err := json.Unmarshal(c1, &command)
  60. if err != nil {
  61. fmt.Printf("json.Unmarshal failed, err:%v\n", err)
  62. }
  63. CoorRepWriteHash(command)
  64. case "05":
  65. var command rabbitmq.MoveCommand
  66. err := json.Unmarshal(c1, &command)
  67. if err != nil {
  68. fmt.Printf("json.Unmarshal failed, err:%v\n", err)
  69. }
  70. CoorMove(command)
  71. case "06":
  72. var command rabbitmq.TempCacheReport
  73. err := json.Unmarshal(c1, &command)
  74. if err != nil {
  75. fmt.Printf("json.Unmarshal failed, err:%v\n", err)
  76. }
  77. TempCacheReport(command)
  78. case "07":
  79. var command rabbitmq.HeartReport
  80. err := json.Unmarshal(c1, &command)
  81. if err != nil {
  82. fmt.Printf("json.Unmarshal failed, err:%v\n", err)
  83. }
  84. HeartReport(command)
  85. }
  86. err := d.Ack(false)
  87. if err != nil {
  88. println(err)
  89. }
  90. }
  91. }()
  92. <-forever
  93. }

本项目旨在将云际存储公共基础设施化,使个人及企业可低门槛使用高效的云际存储服务(安装开箱即用云际存储客户端即可,无需关注其他组件的部署),同时支持用户灵活便捷定制云际存储的功能细节。

Contributors (1)