Skip to content

Commit

Permalink
bump version
Browse files Browse the repository at this point in the history
Also add some other updates to example services
  • Loading branch information
brianz committed Jun 24, 2016
1 parent 1d29594 commit d110caa
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 18 deletions.
5 changes: 3 additions & 2 deletions examples/calculator_service/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ WORKDIR /code

RUN pip install uwsgi

ADD requirements.txt /code/
RUN pip install -r requirements.txt
# ADD requirements.txt /code/
# RUN pip install -r requirements.txt
RUN pip install -e git+https://github.com/brianz/servant.git#egg=servant

COPY . /code/
RUN pip install -e .
40 changes: 29 additions & 11 deletions examples/calculator_service/test_calculator.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import servant.client

client = servant.client.Client('calculator_service', version=1)
calc_client = servant.client.Client('calculator_service', version=1)
simple_client = servant.client.Client('simple_service', version=1)
calc_client2 = servant.client.Client('calculator_service', version=2)

# Uncomment this line and change the connection settings in order to hit an HTTP version of the
# service
# client.configure('http', host='192.168.88.100', port=8888)
Expand All @@ -9,7 +12,7 @@ def _handle_error(response):
print response.errors, response.field_errors


def do_add():
def do_add(client):
response = client.add(number1=10, number2=15)

if response.is_error():
Expand All @@ -18,7 +21,7 @@ def do_add():
print response.result


def do_subtract():
def do_subtract(client):
response = client.subtract(number1=10, number2=15)

if response.is_error():
Expand All @@ -27,7 +30,7 @@ def do_subtract():
print response.result


def do_divide():
def do_divide(client):
response = client.divide(numerator=100, denominator=6)
# Here are some examples of requests which throw errors
#response = client.divide(numerator=100, denominator=0)
Expand All @@ -38,13 +41,28 @@ def do_divide():
else:
print '%s / %s = %s' % (response.numerator, response.denominator, response.quotient)

def do_multiply(client):
response = client.multiply(number1=12, number2=12)

if response.is_error():
print response.errors
else:
print response.result


calc_client.configure('http', host='192.168.88.100', port=8888)
calc_client2.configure('http', host='192.168.88.100', port=8888)

do_divide()
do_divide(calc_client)

#response = simple_client.get_theater_listing(theater_id=123)
#if not response.is_error():
# for movie in response.movies:
# print movie
#else:
# print response.text
#

client = servant.client.Client('calculator_service', version=2)
response = client.multiply(number1=12, number2=12)
if response.is_error():
print response.errors
else:
print response.result
do_add(calc_client2)
#calc_client2.service_name = 'fooely'
#do_multiply(calc_client2)
20 changes: 20 additions & 0 deletions examples/simple_service/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from setuptools import setup, find_packages

setup(
name = 'simple_service',
packages=find_packages(),
version = '1.0',
description = 'Example application with Servant',
author='Brian Zambrano',
author_email='[email protected]',
classifiers=[
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'License :: OSI Approved :: GNU General Public License (GPL)',
'Operating System :: OS Independent',
'Development Status :: 1 - Planning',
'Environment :: Console',
'Intended Audience :: Developers',
'Topic :: System :: Distributed Computing',
]
)
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def _make_request(self):
return response.json()


class MovieField(Action):
class MovieField(servant.fields.ContainerField):
name = servant.fields.StringField()
director = servant.fields.StringField()
release_date = servant.fields.DateTimeField()
Expand All @@ -138,10 +138,10 @@ class TheaterListingAction(Action):
)
theater_name = servant.fields.StringField(
in_response=True,
max_length=12
max_length=48,
)
movies = servant.fields.ListField(
servant.fields.ModelField(MovieField),
MovieField,
in_response=True,
)

Expand All @@ -157,7 +157,6 @@ def get_movies_from_db(self, theater_id):
'director': 'Peter Farrelly, Bobby Farrelly',
'release_date': datetime(2014, 11, 5)},
),
'brian',
]

def run(self, **kwargs):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
setup(
name='servant',
packages=find_packages(exclude=['test', 'examples', 'examples.*']),
version = '0.1.2',
version = '0.1.3',
description = 'A library for building services',
author='Brian Zambrano',
author_email='[email protected]',
Expand Down

0 comments on commit d110caa

Please sign in to comment.