本文整理匯總了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()