databus.py 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. # @Date : 2017-12-25 下午2:43
  4. # @Author : Hedan (hedan@bilibili.com)
  5. # @file : databusTest
  6. import json
  7. import redis
  8. # [databus]
  9. # key = "4ba46ba31f9a44ef"
  10. # secret = "99985eb4451cfb1b899ca0fbe3c4bdc8"
  11. # group = "AccountLog-MainAccount-P"
  12. # topic = "AccountLog-T"
  13. # action = "pub"
  14. # name = "member-service/databus"
  15. # proto = "tcp"
  16. # addr = "172.16.33.158:6205"
  17. # idle = 100
  18. # active = 100
  19. # dialTimeout = "1s"
  20. # readTimeout = "60s"
  21. # writeTimeout = "1s"
  22. # idleTimeout = "10s"
  23. """参考文档 http://info.bilibili.co/pages/viewpage.action?pageId=3670491
  24. key 服务配置中databus的key
  25. value 服务配置中databus的value
  26. host和port 配置服务中databus的host和port
  27. group-topic 一个group对应一个topic(开发申请)
  28. """
  29. #每日登录 passport 获得5经验值
  30. # data_passport ={
  31. # 'mid':4780461,
  32. # 'loginip':1726481463,
  33. # "timestamp":1516517576,
  34. # }
  35. # auth_passport = '4ba46ba31f9a44ef:99985eb4451cfb1b899ca0fbe3c4bdc8@PassportLog-MainAccount-P/topic=PassportLog-T&role=pub&offset=new'
  36. # rc = redis.Redis(host='172.16.33.158', port=6205, socket_keepalive=True)
  37. # print rc.execute_command('auth',auth_passport)
  38. # msg = json.dumps(data_passport, ensure_ascii=False)
  39. # rc.set("1023", msg)
  40. # 每日登录 account 获得5经验值
  41. # data_passport ={
  42. # 'mid':110000092,
  43. # 'loginip':1726481463,
  44. # "timestamp":1516517576,
  45. # }
  46. # auth_passport = '4ba46ba31f9a44ef:99985eb4451cfb1b899ca0fbe3c4bdc8@AccountLoginAward-MainAccount-P/topic=AccountLoginAward-T&role=pub&offset=new'
  47. # rc = redis.Redis(host='172.16.33.158', port=6205, socket_keepalive=True)
  48. # print rc.execute_command('auth',auth_passport)
  49. # msg = json.dumps(data_passport, ensure_ascii=False)
  50. # rc.set("1023", msg)
  51. # 每日首次分享视频 archive 获得5经验值
  52. # data_archive ={
  53. # 'event':"share",
  54. # 'mid':110000092,
  55. # 'ip':"127.0.0.1",
  56. # "ts":111,
  57. # }
  58. # auth_archive = '4ba46ba31f9a44ef:99985eb4451cfb1b899ca0fbe3c4bdc8@AccountExp-MainAccount-P/topic=AccountExp-T&role=pub&offset=new'
  59. # rc = redis.Redis(host='172.16.33.158', port=6205, socket_keepalive=True)
  60. # print rc.execute_command('auth',auth_archive)
  61. # msg = json.dumps(data_archive, ensure_ascii=False)
  62. # rc.set("1023", msg)
  63. #
  64. #
  65. # 每日首次分享视频 archive 获得5经验值
  66. data_archive ={
  67. 'event':"view",
  68. # 'mid':110000092,
  69. 'mid':4780461,
  70. 'ip':"127.0.0.1",
  71. "ts":1521745000,
  72. }
  73. auth_archive = '4ba46ba31f9a44ef:99985eb4451cfb1b899ca0fbe3c4bdc8@AccountExp-MainAccount-P/topic=AccountExp-T&role=pub&offset=new'
  74. rc = redis.Redis(host='172.16.33.158', port=6205, socket_keepalive=True)
  75. print rc.execute_command('auth',auth_archive)
  76. msg = json.dumps(data_archive, ensure_ascii=False)
  77. rc.set("1023", msg)
  78. # 每日首次观看 history 获得5经验值
  79. # data_history ={
  80. # "action":"insert",
  81. # "table":"aso_account",
  82. # "data":{"mid":110000193,
  83. # "userid":"test_dan06",
  84. # "uname":"test_dan08",
  85. # "pwd":"6cfbf96b8f0eb2e0a82b46a4236e8883",
  86. # "salt":"D8fd30Kj",
  87. # "email":"169d9106a74d5e95de71be6cf373af04",
  88. # "tel":"218cb4bf8762354eae473b3b612f707e",
  89. # "country_id":1,
  90. # "mobile_verified":0,
  91. # "isleak":0,
  92. # "mtime":"2018-01-02 17:18:58"},
  93. # "flag":0
  94. # }
  95. # auth_history = '0QEO9F8JuuIxZzNDvklH:0QEO9F8JuuIxZzNDvklI@PassportGameTrans-ENCRYPT-P/topic=PassportGameTrans-T&role=pub&offset=new'
  96. # rc = redis.Redis(host='172.16.33.158', port=6205, socket_keepalive=True)
  97. # print rc.execute_command('auth',auth_history)
  98. # msg = json.dumps(data_history, ensure_ascii=False)
  99. # rc.set("110000193", msg)
  100. # data_history ={
  101. # "action":"insert",
  102. # "table":"aso_account",
  103. # "data":{"mid":110000194,
  104. # "userid":"test_dan07",
  105. # "uname":"test_dan07",
  106. # "pwd":"d2c9d4acdfe9942979d7b4d3e711d499",
  107. # "salt":"5Brw3JuP",
  108. # "email":"169d9106a74d5e95de71be6cf373af04",
  109. # "tel":"b65919197178b5db6ed5f85a229dfaf9",
  110. # "country_id":1,
  111. # "mobile_verified":0,
  112. # "isleak":0,
  113. # "mtime":"2018-01-02 17:18:58"},
  114. # "flag":0
  115. # }
  116. # auth_history = '0QEO9F8JuuIxZzNDvklH:0QEO9F8JuuIxZzNDvklI@PassportGameTrans-ENCRYPT-P/topic=PassportGameTrans-T&role=pub&offset=new'
  117. # rc = redis.Redis(host='172.16.33.158', port=6205, socket_keepalive=True)
  118. # print rc.execute_command('auth',auth_history)
  119. # msg = json.dumps(data_history, ensure_ascii=False)
  120. # rc.set("110000193", msg)