本文整理汇总了Python中cocaine.services.Service.get方法的典型用法代码示例。如果您正苦于以下问题:Python Service.get方法的具体用法?Python Service.get怎么用?Python Service.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cocaine.services.Service
的用法示例。
在下文中一共展示了Service.get方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Service
# 需要导入模块: from cocaine.services import Service [as 别名]
# 或者: from cocaine.services.Service import get [as 别名]
elastic = Service('elasticsearch')
##### INDEX #####
print('Index simple message with index "/twitter/tweet/1"')
data = {
'user': '3Hren',
'post_date': now,
'message': 'Hello, Elasticsearch!'
}
print('Result:', elastic.index(json.dumps(data), 'twitter', 'tweet', '1').get())
print('')
##### GET #####
print('And now get it')
print(elastic.get('twitter', 'tweet', '1').get())
print('')
##### INDEX GENERATE #####
print('Index simple message with id generated and get it')
data = {
'user': '3Hren',
'post_date': now,
'message': 'Hello!'
}
status, index = elastic.index(json.dumps(data), 'twitter', 'tweet').get()
print([status, index])
print(elastic.get('twitter', 'tweet', '{0}'.format(index)).get())
print('')
示例2: len
# 需要导入模块: from cocaine.services import Service [as 别名]
# 或者: from cocaine.services.Service import get [as 别名]
from cocaine.services import Service
import struct
event = '[email protected]'
data = ''
data_size = len(data)
event_size = len(event)
flags = 1
status = 0
__key = 0
src_key = 3
packed = struct.pack('<64sQQiiii32s%ds%ds' % (event_size, data_size),
"this is id",
data_size,
flags,
event_size,
status,
__key,
src_key,
"this is address",
event,
data)
response = Service('queue', hostname = 'localhost', port = 10053).enqueue('pop', packed, 'localhost-queue-1')
print response.get()