deliveryhero / lymph Goto Github PK
View Code? Open in Web Editor NEWframework for Python services
License: Other
framework for Python services
License: Other
If I call self.request with a service type that doesn't match the method name, Some of the time it generates warning like: '2015-10-16 11:40:51,205 [WARNING] lymph.core.container: unsupported service type: echo - trace_id="7c4a6eed669b44e0b0decc1189c9a02c"' and throws a lymph.RpcError, but others it returns a value.
result = self.request('lymph', 'echo.upper', { 'text' : 'delay_%f' % self.delay } )
I am not sure which is the incorrect behavior. I may not be understanding the encapsulation, but the demos made it seem as if the service type was the parent of the method name, in which case I would expect the above to fail.
Here is some code to reproduce the problem, it uses the same config as demo
from __future__ import print_function, unicode_literals
import time
import random
import gevent
import lymph
from lymph.core import trace
class Client(lymph.Interface):
delay = 2.0
def on_start(self):
super(Client, self).on_start()
gevent.spawn(self.loop)
def apply_config(self, config):
super(Client, self).apply_config(config);
self.delay = config.get('delay', 2.0)
def loop(self):
while self.delay > .05:
time.sleep(self.delay)
trace.set_id()
try:
result = self.request('lymph', 'echo.upper', { 'text' : 'delay_%f' % self.delay } )
except lymph.RpcError:
print("RpcError (retry)")
continue
print("result = %s" % result._body)
self.delay = self.delay / 2
lymph fails when setting trace-id header in case the return type from WebInterface is not correct type. lymph should probably check for this and raise before.
Traceback (most recent call last):
File "/home/eren.gueven/.virtualenvs/ars/local/lib/python2.7/site-packages/gevent/pywsgi.py", line 508, in handle_one_response
self.run_application()
File "/home/eren.gueven/.virtualenvs/ars/local/lib/python2.7/site-packages/gevent/pywsgi.py", line 494, in run_application
self.result = self.application(self.environ, self.start_response)
File "/home/eren.gueven/.virtualenvs/ars/local/lib/python2.7/site-packages/werkzeug/wrappers.py", line 291, in application
return f(*args[:-2] + (request,))(*args[-2:])
File "/home/eren.gueven/.virtualenvs/ars/local/lib/python2.7/site-packages/lymph/web/interfaces.py", line 114, in dispatch_request
response.headers['X-Trace-Id'] = trace.get_id()
AttributeError: 'NoneType' object has no attribute 'headers'
The interface name is used to identify the interface when it is installed in a container. There is a method in the container that allows you to install interfaces.
def install_interface(self, cls, interface_name=None):
The interface_name
is associated to the interface and that is what is used to identify the interface too, including discovery.
Now when you have an interface, you can change the name
of the interface if you have access to the interface instance and that will not update the container.
Eg.
echo_interface = container.installed_interfaces['echo']
echo_interface.name = 'something-else'
This would not break the request call to the the interface, but it indicates that if you change the name the of the interface you would be able to discover it with the new name runtime.
To follow the discussion and possibly a solution checkout this discussion on the PR[https://github.com//pull/37#discussion-diff-20519884]
Hi Team,
I want to enable HTTPS in Lymph. where should i configure the SSL parameters for the same?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.