谷歌云事件系统。
gces的Python项目详细描述
GCES-谷歌云事件系统
目标
这个项目的目标是使使用accross服务的全局事件发布者/事件订阅者系统更加容易。
架构
快速事件通知示例
fromgcesimportEventPublisherept=EventPublisher('gces')ept.notify('SIGNUP_EVENT',{'user_id':1234})ept.notify('LOGIN_EVENT',{'user_id':4321})
快速事件订阅示例
importtimefromgcesimport(EventSubscriber)defexample_run_subscriber_function(data):print("Data Received: {}".format(data))TOPIC_NAME='gces'SUBSCRIBER_NAME='gces_example'es=EventSubscriber(TOPIC_NAME,SUBSCRIBER_NAME)es.register_fsub('EXAMPLE_RUN_FUNCTION_PROCCESS'example_run_subscriber_function)es.start()if__name__=='__main__':try:whileTrue:time.sleep(200)exceptKeyboardInterrupt:print('Bye!!!!')
谷歌云凭据
- 在Google处创建凭据
- 导出google_application_credentials=$(pwd)/<;credentials_file>;.json