本文整理匯總了Python中nameko.standalone.rpc.ClusterRpcProxy方法的典型用法代碼示例。如果您正苦於以下問題:Python rpc.ClusterRpcProxy方法的具體用法?Python rpc.ClusterRpcProxy怎麽用?Python rpc.ClusterRpcProxy使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類nameko.standalone.rpc
的用法示例。
在下文中一共展示了rpc.ClusterRpcProxy方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: post
# 需要導入模塊: from nameko.standalone import rpc [as 別名]
# 或者: from nameko.standalone.rpc import ClusterRpcProxy [as 別名]
def post(self):
if not user_authenticated():
return 'Please log in', 401
email = session['email']
data = request.get_json(force=True)
try:
message = data['message']
except KeyError:
return 'No message given', 400
with ClusterRpcProxy(config) as rpc:
rpc.message_service.save_message(email, message)
return '', 204
示例2: get
# 需要導入模塊: from nameko.standalone import rpc [as 別名]
# 或者: from nameko.standalone.rpc import ClusterRpcProxy [as 別名]
def get(self):
with ClusterRpcProxy(config) as rpc:
messages = rpc.message_service.get_all_messages()
return jsonify(messages)
示例3: test_peopledata_persist
# 需要導入模塊: from nameko.standalone import rpc [as 別名]
# 或者: from nameko.standalone.rpc import ClusterRpcProxy [as 別名]
def test_peopledata_persist():
with ClusterRpcProxy(config) as cluster_rpc:
out = cluster_rpc.people_data_persistence.save.call_async('people.csv')
print(out.result())
開發者ID:PacktPublishing,項目名稱:Mastering-Python-Design-Patterns-Second-Edition,代碼行數:6,代碼來源:test_service_second.py
示例4: _get_nameko_connection
# 需要導入模塊: from nameko.standalone import rpc [as 別名]
# 或者: from nameko.standalone.rpc import ClusterRpcProxy [as 別名]
def _get_nameko_connection(self):
proxy = ClusterRpcProxy(
self._config,
timeout=self._config.get('RPC_TIMEOUT', None)
)
return proxy.start()
示例5: __init__
# 需要導入模塊: from nameko.standalone import rpc [as 別名]
# 或者: from nameko.standalone.rpc import ClusterRpcProxy [as 別名]
def __init__(self, pool, config):
self._pool = weakref.proxy(pool)
self._proxy = ClusterRpcProxy(config, context_data=copy.deepcopy(pool.context_data), timeout=pool.timeout)
self._rpc = None
self._enable_rpc_call = False
示例6: rpc_get_news
# 需要導入模塊: from nameko.standalone import rpc [as 別名]
# 或者: from nameko.standalone.rpc import ClusterRpcProxy [as 別名]
def rpc_get_news(news_type, news_id):
with ClusterRpcProxy(CONFIG_RPC) as rpc:
if news_type == 'famous':
news = rpc.query_famous.get_news(news_id)
elif news_type == 'sports':
news = rpc.query_sports.get_news(news_id)
elif news_type == 'politics':
news = rpc.query_politics.get_news(news_id)
else:
return erro_response('Invalid News type', 400)
return {
'status': 'success',
'news': json.loads(news)
}
示例7: rpc_get_all_news
# 需要導入模塊: from nameko.standalone import rpc [as 別名]
# 或者: from nameko.standalone.rpc import ClusterRpcProxy [as 別名]
def rpc_get_all_news(news_type, num_page, limit):
with ClusterRpcProxy(CONFIG_RPC) as rpc:
if news_type == 'famous':
news = rpc.query_famous.get_all_news(num_page, limit)
elif news_type == 'sports':
news = rpc.query_sports.get_all_news(num_page, limit)
elif news_type == 'politics':
news = rpc.query_politics.get_all_news(num_page, limit)
else:
return erro_response('Invalid News type', 400)
return {
'status': 'success',
'news': json.loads(news)
}
示例8: rpc_command
# 需要導入模塊: from nameko.standalone import rpc [as 別名]
# 或者: from nameko.standalone.rpc import ClusterRpcProxy [as 別名]
def rpc_command(news_type, data):
with ClusterRpcProxy(CONFIG_RPC) as rpc:
if news_type == 'famous':
news = rpc.command_famous.add_news(data)
elif news_type == 'sports':
news = rpc.command_sports.add_news(data)
elif news_type == 'politics':
news = rpc.command_politics.add_news(data)
else:
return erro_response('Invalid News type', 400)
return {
'status': 'success',
'news': news,
}
示例9: rpc_get_news
# 需要導入模塊: from nameko.standalone import rpc [as 別名]
# 或者: from nameko.standalone.rpc import ClusterRpcProxy [as 別名]
def rpc_get_news(news_type, news_id):
with ClusterRpcProxy(BROKER_CONFIG) as rpc:
if news_type == 'famous':
news = rpc.query_famous.get_news(news_id)
elif news_type == 'sports':
news = rpc.query_sports.get_news(news_id)
elif news_type == 'politics':
news = rpc.query_politics.get_news(news_id)
else:
return error_response('Invalid News type', 400)
return {
'status': 'success',
'news': json.loads(news)
}
示例10: rpc_get_all_news
# 需要導入模塊: from nameko.standalone import rpc [as 別名]
# 或者: from nameko.standalone.rpc import ClusterRpcProxy [as 別名]
def rpc_get_all_news(news_type, num_page, limit):
with ClusterRpcProxy(BROKER_CONFIG) as rpc:
if news_type == 'famous':
news = rpc.query_famous.get_all_news(num_page, limit)
elif news_type == 'sports':
news = rpc.query_sports.get_all_news(num_page, limit)
elif news_type == 'politics':
news = rpc.query_politics.get_all_news(num_page, limit)
else:
return error_response('Invalid News type', 400)
return {
'status': 'success',
'news': json.loads(news)
}
示例11: rpc_get_news
# 需要導入模塊: from nameko.standalone import rpc [as 別名]
# 或者: from nameko.standalone.rpc import ClusterRpcProxy [as 別名]
def rpc_get_news(news_type, news_id):
with ClusterRpcProxy(BROKER_CONFIG) as rpc:
if news_type == 'famous':
news = rpc.query_famous.get_news(news_id)
elif news_type == 'sports':
news = rpc.query_sports.get_news(news_id)
elif news_type == 'politics':
news = rpc.query_politics.get_news(news_id)
else:
return erro_response('Invalid News type', 400)
return {
'status': 'success',
'news': json.loads(news)
}
示例12: rpc_get_all_news
# 需要導入模塊: from nameko.standalone import rpc [as 別名]
# 或者: from nameko.standalone.rpc import ClusterRpcProxy [as 別名]
def rpc_get_all_news(news_type, num_page, limit):
with ClusterRpcProxy(BROKER_CONFIG) as rpc:
if news_type == 'famous':
news = rpc.query_famous.get_all_news(num_page, limit)
elif news_type == 'sports':
news = rpc.query_sports.get_all_news(num_page, limit)
elif news_type == 'politics':
news = rpc.query_politics.get_all_news(num_page, limit)
else:
return erro_response('Invalid News type', 400)
return {
'status': 'success',
'news': json.loads(news)
}
示例13: rpc_command
# 需要導入模塊: from nameko.standalone import rpc [as 別名]
# 或者: from nameko.standalone.rpc import ClusterRpcProxy [as 別名]
def rpc_command(news_type, data):
with ClusterRpcProxy(BROKER_CONFIG) as rpc:
if news_type == 'famous':
news = rpc.command_famous.add_news(data)
elif news_type == 'sports':
news = rpc.command_sports.add_news(data)
elif news_type == 'politics':
news = rpc.command_politics.add_news(data)
else:
return erro_response('Invalid News type', 400)
return {
'status': 'success',
'news': news,
}
示例14: rpc_command
# 需要導入模塊: from nameko.standalone import rpc [as 別名]
# 或者: from nameko.standalone.rpc import ClusterRpcProxy [as 別名]
def rpc_command(news_type, data):
with ClusterRpcProxy(BROKER_CONFIG) as rpc:
if news_type == 'famous':
news = rpc.command_famous.add_news(data)
elif news_type == 'sports':
news = rpc.command_sports.add_news(data)
elif news_type == 'politics':
news = rpc.command_politics.add_news(data)
else:
return error_response('Invalid News type', 400)
return {
'status': 'success',
'news': news,
}